server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Support /kifi/ subpath if forwarded with prefix by reverse proxy rewrite ^/kifi/(.*)$ /$1 break; rewrite ^/kifi$ / break; # Gzip compression for Flutter Web assets (JS, WASM, CSS, JSON, Fonts) gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript application/wasm image/svg+xml font/woff font/woff2; # Service Worker & manifest: no cache to ensure immediate updates location ~* (flutter_service_worker\.js|manifest\.json|version\.json)$ { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; try_files $uri =404; } # Static assets (images, fonts, canvaskit, icons, js chunks): long cache location ~* \.(?:ico|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|wasm)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Main SPA routing: fall back to index.html for all subroutes location / { add_header Cache-Control "no-cache, no-store, must-revalidate"; try_files $uri $uri/ /index.html; } # Error pages error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }