fix: serve sw.js and manifest.json with no-cache header

Cloudflare was caching sw.js for 4 hours (default JS caching),
preventing service worker updates from reaching clients.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-25 17:55:52 -07:00
parent c4972079dd
commit 23083c32b0
1 changed files with 2 additions and 2 deletions

View File

@ -2936,8 +2936,8 @@ async function serveStatic(path: string, url?: URL): Promise<Response | null> {
const headers: Record<string, string> = { "Content-Type": getContentType(path) };
if (url?.searchParams.has("v")) {
headers["Cache-Control"] = "public, max-age=31536000, immutable";
} else if (path.endsWith(".html")) {
// HTML must revalidate so browsers pick up new hashed JS/CSS references
} else if (path.endsWith(".html") || path === "sw.js" || path === "manifest.json") {
// HTML, service worker, and manifest must revalidate every time
headers["Cache-Control"] = "no-cache";
} else if (path.startsWith("assets/")) {
// Vite content-hashed assets are safe to cache long-term