From d071c8228f56b16ac25f3ddcd734ba0a23c4f77b Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sat, 2 May 2026 07:26:06 -0600 Subject: [PATCH] Add cache busting to asset urls to bust assets with bad headers --- src/server/PublicAssetManifest.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/PublicAssetManifest.ts b/src/server/PublicAssetManifest.ts index 400e80f8f..8d1258d95 100644 --- a/src/server/PublicAssetManifest.ts +++ b/src/server/PublicAssetManifest.ts @@ -33,6 +33,9 @@ const ROOT_PUBLIC_FILES = new Set([ const manifestCache = new Map(); +// Bump this to force-invalidate all CDN-cached assets (e.g. after a bad deploy with wrong cache headers). +const CACHE_BUST_VERSION = "2"; + type DerivedPublicAssetRenderContext = { resourcesDir: string; relativePath: string; @@ -50,11 +53,19 @@ function toPosixPath(filePath: string): string { function createContentHash(filePath: string): string { const content = fs.readFileSync(filePath); - return createHash("sha256").update(content).digest("hex").slice(0, 12); + return createHash("sha256") + .update(CACHE_BUST_VERSION) + .update(content) + .digest("hex") + .slice(0, 12); } function createStringHash(content: string): string { - return createHash("sha256").update(content).digest("hex").slice(0, 12); + return createHash("sha256") + .update(CACHE_BUST_VERSION) + .update(content) + .digest("hex") + .slice(0, 12); } function createHashedAssetUrl(relativePath: string, hash: string): string {