fix: serve service worker with no-cache header (#13716)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-09-09 12:00:22 -04:00
1 parent dafda3de46
commit cd808bcd92
1 file changed
+7 -1
+7 -1
View File
@@ -71,9 +71,15 @@ if (env.isProduction) {
// Hashed static assets get 1 year expiry plus immutable flag
maxAge: Day.ms * 365,
immutable: true,
setHeaders: (res) => {
setHeaders: (res, filePath) => {
res.setHeader("Service-Worker-Allowed", "/");
res.setHeader("Access-Control-Allow-Origin", "*");
// The service worker is not hashed and must always be revalidated
// so that browsers detect and install new versions.
if (path.basename(filePath) === "sw.js") {
res.setHeader("Cache-Control", "no-cache");
}
},
});
} catch (err) {