From 2f5bcf479aff04f9c34fdbeaa23ab25fabbaef7f Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sat, 7 Mar 2026 20:12:11 +0100 Subject: [PATCH] fix: add Cache-Control no-cache for HTML pages to prevent stale CDN content Bunny CDN was caching HTML pages, so after deploys the browser kept loading old JS bundles with expired Server Action hashes. This header tells the CDN to always revalidate with the origin. Static assets (/_next/static/*) are excluded since they are content-hashed. --- next.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/next.config.ts b/next.config.ts index a8ec28d..0052619 100644 --- a/next.config.ts +++ b/next.config.ts @@ -47,6 +47,14 @@ const nextConfig: NextConfig = { }, async headers() { return [ + { + // * Prevent CDN/browser from serving stale HTML after deploys. + // * Static assets (/_next/static/*) are content-hashed and cached separately by Next.js. + source: '/((?!_next/static|_next/image).*)', + headers: [ + { key: 'Cache-Control', value: 'no-cache, must-revalidate' }, + ], + }, { source: '/(.*)', headers: [