diff --git a/nginx.conf b/nginx.conf index b7d7d7551..ee0571d5e 100644 --- a/nginx.conf +++ b/nginx.conf @@ -176,15 +176,18 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } - # Updated Root location - with 1 second cache + # Root location with no caching location = / { proxy_pass http://127.0.0.1:3000; - add_header Cache-Control "public, max-age=1"; # 1 second cache + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; - proxy_cache STATIC; - proxy_cache_valid 200 302 1s; # Cache successful responses for 1 second - proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; - proxy_cache_lock on; + # Disable proxy cache for index.html + proxy_no_cache 1; + proxy_cache_bypass 1; + + # Show cache status in response headers add_header X-Cache-Status $upstream_cache_status; proxy_http_version 1.1; @@ -196,22 +199,7 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } - # Location for index.html specifically - location ~* /index\.html$ { - proxy_pass http://127.0.0.1:3000; - add_header Cache-Control "public, max-age=1"; - proxy_cache STATIC; - proxy_cache_valid 200 302 1s; - proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; - proxy_cache_lock on; - add_header X-Cache-Status $upstream_cache_status; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - + # Default location for all other requests location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; diff --git a/src/server/Master.ts b/src/server/Master.ts index d5062d389..3fce4664c 100644 --- a/src/server/Master.ts +++ b/src/server/Master.ts @@ -30,9 +30,14 @@ app.use( // You can conditionally set different cache times based on file types if (path.endsWith(".html")) { // Set HTML files to no-cache to ensure Express doesn't send 304s - res.setHeader("Cache-Control", "no-cache, must-revalidate"); + res.setHeader( + "Cache-Control", + "no-store, no-cache, must-revalidate, proxy-revalidate", + ); res.setHeader("Pragma", "no-cache"); res.setHeader("Expires", "0"); + // Prevent conditional requests + res.setHeader("ETag", ""); } else if (path.match(/\.(js|css|svg)$/)) { // JS, CSS, SVG get long cache with immutable res.setHeader("Cache-Control", "public, max-age=31536000, immutable");