/ nginx.conf
nginx.conf
1 server { 2 listen 80; 3 server_name _; 4 5 root /usr/share/nginx/html; 6 index index.html; 7 8 # Gzip compression 9 gzip on; 10 gzip_vary on; 11 gzip_min_length 1024; 12 gzip_types 13 text/plain 14 text/css 15 text/javascript 16 application/javascript 17 application/json 18 application/xml 19 image/svg+xml; 20 21 # Long-lived cache for hashed static assets (JS, CSS, images) 22 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { 23 expires 1y; 24 add_header Cache-Control "public, immutable"; 25 access_log off; 26 } 27 28 # No cache for the HTML entry point 29 location = /index.html { 30 add_header Cache-Control "no-cache, no-store, must-revalidate"; 31 } 32 33 # SPA fallback — React Router handles all client-side routes 34 location / { 35 try_files $uri $uri/ /index.html; 36 } 37 }