s-maxage ISR calculation
Unanswered
Paper wasp posted this in #help-forum
Paper waspOP
When using Next.js ISR mode with a CDN, the s-maxage header is equal to the revalidation time. OpenNext changed this behavior, and Vercel seems to work like OpenNext aswell.
the problem is well explain in OpenNext docs:
"Setting s-maxage to the same value for every request to the same page could be a bad idea. Next can serve different content based on if you request the full html or are doing client side navigation (RSC or JSON for page router)
This can cause inconsistencies in the cache with ISR especially when you can have big revalidation time.
For example, let's assume you use app router, you have a link to your homepage in your main navbar and you set ISR to 1 day. Every other page will have a different RSC cache entry (for client side navigation). This will result in as many cache entry as you have pages in your app which all will have that same 1 day s-maxage value but could have been requested at very different time. This could lead to some pages being served with stale content for as long as 2 day."
Is there any config that would allow us to do the same without OpenNext and Vercel (i.e sending the s-maxage value equals to (invalidation time - cache age) when we have a Next cache HIT?
the problem is well explain in OpenNext docs:
"Setting s-maxage to the same value for every request to the same page could be a bad idea. Next can serve different content based on if you request the full html or are doing client side navigation (RSC or JSON for page router)
This can cause inconsistencies in the cache with ISR especially when you can have big revalidation time.
For example, let's assume you use app router, you have a link to your homepage in your main navbar and you set ISR to 1 day. Every other page will have a different RSC cache entry (for client side navigation). This will result in as many cache entry as you have pages in your app which all will have that same 1 day s-maxage value but could have been requested at very different time. This could lead to some pages being served with stale content for as long as 2 day."
Is there any config that would allow us to do the same without OpenNext and Vercel (i.e sending the s-maxage value equals to (invalidation time - cache age) when we have a Next cache HIT?