From 61363f81be4680eee6857be88e23f2bef075b8f2 Mon Sep 17 00:00:00 2001 From: Local Administrator Date: Wed, 3 Jun 2026 12:56:27 +0000 Subject: [PATCH] fix(cache): no-store on / and /news so CF edge never sticks on the dynamic hero/feed Next.js sets a long s-maxage on prerendered HTML even for routes flagged force-dynamic; Cloudflare then caches that response and ignores subsequent dynamic renders. Explicit Cache-Control + CDN-Cache-Control no-store on / and /news/* keeps the hero swap visible immediately after a DB change. --- next.config.mjs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/next.config.mjs b/next.config.mjs index ec42522..66db4d1 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -49,6 +49,23 @@ const nextConfig = { { key: 'Cache-Control', value: 'public, max-age=86400, stale-while-revalidate=604800' }, ], }, + { + // Homepage and news routes must never be cached at edge — the hero + // and feed are DB-driven via force-dynamic, but Next.js sets a + // long s-maxage on prerendered HTML which CF then caches for a year. + source: '/', + headers: [ + { key: 'Cache-Control', value: 'no-store, must-revalidate' }, + { key: 'CDN-Cache-Control', value: 'no-store' }, + ], + }, + { + source: '/news/:path*', + headers: [ + { key: 'Cache-Control', value: 'no-store, must-revalidate' }, + { key: 'CDN-Cache-Control', value: 'no-store' }, + ], + }, ]; },