From beb53a2e0ce533a2d51e0eb23a0e1be795c8489b Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Fri, 6 Nov 2026 13:48:07 +0100 Subject: [PATCH] Serve the wasm and scripts gzip-compressed (packed at build time) Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 2 ++ nginx.conf | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 84224d2..261bd8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,4 +31,6 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf COPY www/ /usr/share/nginx/html/ COPY --from=build /out/ /usr/share/nginx/html/ COPY --from=standalone /out/standalone/ /usr/share/nginx/html/standalone/ +# packed once for gzip_static (nginx.conf) +RUN cd /usr/share/nginx/html && gzip -k -9 dungeoncraft.wasm mq_js_bundle.js standalone/DungeonCraft.html EXPOSE 80 diff --git a/nginx.conf b/nginx.conf index bf4fb80..2c1d0a4 100644 --- a/nginx.conf +++ b/nginx.conf @@ -4,6 +4,13 @@ server { index index.html; # test build: always reload fresh files add_header Cache-Control "no-cache"; + # compressed downloads: the big files are packed once at build time (*.gz, see Dockerfile), + # the rest on the fly (the wasm goes from about 8.8 MB to 2.6 MB) + gzip_static on; + gzip on; + gzip_types application/wasm application/javascript text/css application/json application/manifest+json image/svg+xml; + gzip_min_length 1024; + gzip_vary on; location / { try_files $uri $uri/ =404; }