server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; charset utf-8; gzip on; gzip_types text/plain text/css application/json application/javascript image/svg+xml; gzip_min_length 256; # Long-cache static assets (CSS, JS, images, fonts) location ~* \.(css|js|woff2?|ttf|otf|eot|svg|webp|png|jpg|jpeg|ico|gif)$ { expires 1y; add_header Cache-Control "public, immutable"; add_header Vary Accept-Encoding; } # HTML pages — no-cache so updates are picked up immediately location ~* \.html$ { add_header Cache-Control "no-cache, must-revalidate"; } # SPA-style routing: serve index.html for unknown paths location / { try_files $uri $uri/ $uri.html =404; } error_page 404 /404.html; }