Should the revalidate route segment config option update the Cache-Control header? #82015
-
On one of our pages, we've added a dynamic route segment config and set it to:
This changes the page
I then assumed adding a revalidate route segment config e.g.
Would update the
But that's not the case. Based on this 2023 StackOverflow discussion, it should. However, it is 1.5 years old. Is that expected? Does Next.js work out when to revalidate from other response headers instead? We are hosting on Vercel if that makes a difference. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @pauledwards241, Great question! Here’s how Next.js handles the revalidate route segment config and Cache-Control headers currently: Setting export const revalidate = 600 does not directly update the Cache-Control header to max-age=600. Instead, Next.js manages revalidation internally and sets cache headers based on its own logic and hosting platform (like Vercel). For dynamic = 'force-static', Next.js adds Cache-Control: public, max-age=0, must-revalidate to ensure the content is fresh but still cached by browsers/CDNs. The actual revalidation timing for ISR is controlled server-side, often by a separate header or platform config, not purely by the Cache-Control max-age. On Vercel, ISR revalidation is handled by their edge network, so you might not see max-age=600 reflected in the response headers, but revalidation happens as configured. So yes, this behavior is expected with current Next.js versions and hosting on Vercel. If you want full control over Cache-Control headers, you might consider setting them manually in route handlers or middleware. Let me know if you want examples on how to customize caching headers or more info on ISR internals! |
Beta Was this translation helpful? Give feedback.
Hi @pauledwards241,
Great question! Here’s how Next.js handles the revalidate route segment config and Cache-Control headers currently:
Setting export const revalidate = 600 does not directly update the Cache-Control header to max-age=600.
Instead, Next.js manages revalidation internally and sets cache headers based on its own logic and hosting platform (like Vercel).
For dynamic = 'force-static', Next.js adds Cache-Control: public, max-age=0, must-revalidate to ensure the content is fresh but still cached by browsers/CDNs.
The actual revalidation timing for ISR is controlled server-side, often by a separate header or platform config, not purely by the Cache-Control max-age.
On Vercel, IS…