Next.js Discord

Discord Forum

Refresh after deployment causes new revalidation (ISR)

Unanswered
Basset Fauve de Bretagne posted this in #help-forum
Open in Discord
Basset Fauve de BretagneOP
Hey community! I’m using the power of ISR to serve static data fresh each 6h. internally I’m using a function that uses fetch with force-cache and revalidation. With the data I attached a now timestamp so I can understand if revalidation is working. I have multiple routes using this function.

Recently noticed that after a new deployment the timestamp from the server looks fresh but if I refresh I get a new one, looks like dedup/memoization is not working —-multiple fetch calls in the server were done.

Anyone facing this?

Thank you!

8 Replies

@joulev Is the timestamp part of the response of that fetch(), or is the timestamp generated in the same function where the fetch() is called?
Basset Fauve de BretagneOP
It’s part of the same function, not part of the fetch. however I also wrapped the function using the cache react (to test just in case) and the result was the same :/
* React.cache only memoises, doesn't cache. if you call the function in generateMetadata and the page component, they would have the same timestamp, but different page reloads will have different timestamps.

* only the fetch is cached, all functions wrapping it are not cached by default. so it explains why the timestamp is not cached.

if you export const revalidate = x in the page, or use unstable_cache, then you can cache the timestamp too
Basset Fauve de BretagneOP
Tks! I got your points! However forgot to mention that it only happens right after the new deployment, after that, the revalidation starts working as expected, static page being served with the same timestamp. My suspicion is that having multiple pages calling same function at build time is causing this inconsistency. Example: after deployment I visit my page and I see it was refreshed 1 minute ago, then I force a browser refresh and I see new one. After this, everything will work as expected.
Basset Fauve de BretagneOP
Yep exactly looks like a bug, maybe related how the file routing is structured in my app etc, will need to keep an eye 👁️, will try to upgrade Nextjs version and add some server logs to debug
i dont think that bug matters though, worst it does is the page is only dynamic for a brief period right? i wouldn't spare any effort trying to fix such a minor bug
Basset Fauve de BretagneOP
Yep 👍