server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # SPA history mode location / { try_files $uri $uri/ /index.html; } # Runtime config — always revalidate so env changes apply after restart location = /config.js { add_header Cache-Control "no-cache, no-store, must-revalidate"; try_files $uri =404; } # Hashed assets — long cache location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } # Service worker / workbox — always revalidate location ~* ^/(sw\.js|workbox-.*\.js)$ { add_header Cache-Control "no-cache"; try_files $uri =404; } gzip on; gzip_types text/css application/javascript application/json image/svg+xml; }