Next.js Discord

Discord Forum

CDN Caching on dynamic routes (Next.js 15)

Unanswered
Channel catfish posted this in #help-forum
Open in Discord
Avatar
Channel catfishOP
Hi team,
I'm having some trouble wanting to leverage the CDN cache for dynamic routes, such as /domain/[slug].
The data is long lived so CDN caching would be ideal.

I tried using export const dynamic = 'force-static'; however, the page then doesn't load until rendering is complete and the Suspense boundaries don't kick in.

I've tried setting Cache-Control header using headers in next.config.js however this doesn't seem to be respected (HTTP response shows Cache-Control header is private).

Using the force-static works great in dev (showing the Suspense fallback etc) but not when deployed to Vercel.

Unfortunately I'm wondering if I might have to split out the data fetching to an API route and have the client request that to get the flexibility I'm after

Any advice would be appreciated 🙂

0 Replies