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.
This commit is contained in:
@@ -49,6 +49,23 @@ const nextConfig = {
|
|||||||
{ key: 'Cache-Control', value: 'public, max-age=86400, stale-while-revalidate=604800' },
|
{ 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' },
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user