server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Serve static files directly; fall back to index.html for SPA routing location / { try_files $uri $uri/ /index.html; } # Cache static assets aggressively (Vite hashes filenames) location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } # Don't log favicon/robots requests location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } # Gzip compression for text-based assets gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; }