From af95c6280c5c879038e09b6c79c88b8285ba7391 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Tue, 7 Jul 2026 21:13:43 +0100 Subject: [PATCH] fix(dashboard): prevent CDN caching of HTML pages to fix stale builds after deploy --- apps/dashboard/src/hooks.server.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/dashboard/src/hooks.server.ts b/apps/dashboard/src/hooks.server.ts index d653c7d8..a4f583c4 100644 --- a/apps/dashboard/src/hooks.server.ts +++ b/apps/dashboard/src/hooks.server.ts @@ -62,6 +62,13 @@ export const handle: Handle = async (args) => { response = await handlePagesRoutes(args); } + // Prevent Cloudflare/CDN from caching HTML pages — stale HTML references old + // hashed JS/CSS bundles after a deploy, causing the app to hang on deep links. + const contentType = response.headers.get('content-type') ?? ''; + if (contentType.includes('text/html')) { + response.headers.set('Cache-Control', 'private, no-cache, must-revalidate'); + } + return applyCspExtensions(response); };