server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Never cache HTML files - ADD THIS location ~* \.html$ { expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; } # Special handling for root index.html - ADD THIS location = / { try_files /index.html =404; expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; } # Handle React Router (SPA) - MODIFY THIS location / { try_files $uri $uri/ @fallback; } # Fallback for SPA routing - ADD THIS location @fallback { rewrite ^.*$ /index.html last; expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; } # Cache static assets with hashes - EXPAND THIS location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { expires 1y; add_header Cache-Control "public, immutable" always; } }