server { listen ${PORT}; server_name _; root /usr/share/nginx/html; index index.html; # Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # index.html — never cache (so deploys serve new chunk references) location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; } # Handle SPA routing - serve index.html for all routes location / { try_files $uri $uri/ /index.html; } # Cache hashed static assets (immutable — filenames change on rebuild) location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; } }