Replies: 5 comments 8 replies
-
Any update from the Vercel team on this one? Does this change with Next13? |
Beta Was this translation helpful? Give feedback.
-
@jaksenko I was investigating a similar issue. I found this from NextJS Docs // This value is considered fresh for ten seconds (s-maxage=10).
// If a request is repeated within the next 10 seconds, the previously
// cached value will still be fresh. If the request is repeated before 59 seconds,
// the cached value will be stale but still render (stale-while-revalidate=59).
//
// In the background, a revalidation request will be made to populate the cache
// with a fresh value. If you refresh the page, you will see the new value.
export async function getServerSideProps({ req, res }) {
res.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)
return {
props: {},
}
}
According to web.dev, a request made outside of the window of All |
Beta Was this translation helpful? Give feedback.
-
None of what I wrote here is true, so you can ignore the rest of this comment. Middleware, like the next.config.js
|
Beta Was this translation helpful? Give feedback.
-
I think I'm seeing this same behavior in our Next.js |
Beta Was this translation helpful? Give feedback.
-
It's now possible to customize |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So I just tried to use Incremental Static Regeneration because it is a nice fit to our use-case: we have an internal CMS that gets updated only once a few days. To speed up the page we set
revalidate: 3600
. We use CloudFront as our CDN. However, after few attempts to verify that the page actually gets refreshed in 1 hour I noticed that Next.js setsCache-Control: s-maxage: 3600, stale-while-revalidate
header. This is very problematic if our server sits behind CloudFront, because now we have 2 layers of cache, each respectingstale-while-revalidate
directive. So request coming after 1h gets old response from CF and CF requests new content in background. Next.js returns old content and refreshes its cache. After another hour CF still returns and old content, but in the background it finally gets a new content from Next.js, although if that content has changed again it still displays outdated one. The cycle never ends.I don't understand why Next.js does that proactively without ability to opt-out. Nobody else uses CDN except for me?
I tried to use On-demand Revalidation as well, but that one is even crazier - a page with
getStaticProps
withoutrevalidate
key getsCache-Control: s-maxage=31536000, stale-while-revalidate
- how Next.js can even think about setting such header to a page url that obviously doesn't change in between builds? Anyone who accesses the page will forever see the old version of it, no matter how many releases behind.Am I missing something extremely important here? Because I have a feeling that Next.js can't be that counter-intuitive.
Beta Was this translation helpful? Give feedback.
All reactions