server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; gzip on; gzip_vary on; gzip_min_length 256; gzip_comp_level 6; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml; # Vite emits hashed filenames in /assets/ — cache aggressively location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # index.html must NOT be cached — it points at the current bundle hash location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; expires off; } # SPA fallback (defensive — your app has no router today, but harmless) location / { try_files $uri $uri/ /index.html; } server_tokens off; }