server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # index.html must never be cached — it references hashed asset filenames # that change on every build. Stale HTML → wrong JS bundle → broken app. location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; } # Hashed JS/CSS/image assets are safe to cache forever — the filename # changes whenever the content changes, so there's no stale-file risk. location ~* \.(?:js|css|woff2?|svg|png|jpg|ico)$ { add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } location / { try_files $uri $uri/ /index.html; } location /api/ { proxy_pass http://server:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; client_max_body_size 20M; } location /uploads/ { proxy_pass http://server:3000; proxy_http_version 1.1; proxy_set_header Host $host; } }