How does the revalidate process in Incremental Static Regeneration work?

Incremental static generation is Inspired by stale-while-revalidate, so there are no intervals.
Lets say that our revalidate value is 60 seconds :

  • first user will visit the page at 100000000000 (random time in milliseconds)
  • next.js will cache the page with an expiry date of 100000060000
  • other user comes at 100000040000, cache is valid, doing nothing (serving cached page)
  • another visitor come at 100000070000, cache is expired, next.js will revalidate the page in the background,but the user still see the old page.
  • last visitor comes at 100000080000 and will se the page with the new data
  • and so on…

After 60 seconds NextJS rebuilds the pages for him and serves the
fresh content.

So no this concept is wrong, next.js will not rebuild the page after n seconds,
but for every request next.js will check if the time elapsed since the last request is > that the expiry date of the cache. if your revalidate value is 1 second, but the next visitor comes after 1 year, next will regenerate the page after one year.

Leave a Comment