have nginx cache index for 1s. (#224)

This is required for A B deployments, the browser wasn't updating due to
conditional caches
This commit is contained in:
evanpelle
2025-03-12 11:03:28 -07:00
committed by Evan
parent 32e8d9f046
commit 88a33329b7
2 changed files with 28 additions and 6 deletions
+4 -2
View File
@@ -30,8 +30,10 @@ app.use(
setHeaders: (res, path) => {
// You can conditionally set different cache times based on file types
if (path.endsWith(".html")) {
// HTML files get shorter cache time
res.setHeader("Cache-Control", "public, max-age=60");
// Set HTML files to no-cache to ensure Express doesn't send 304s
res.setHeader("Cache-Control", "no-cache, must-revalidate");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", "0");
} else if (path.match(/\.(js|css|svg)$/)) {
// JS, CSS, SVG get long cache with immutable
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");