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; }