简体   繁体   中英

What happens if Next.js ISR with the revalidate value is 1 second in Production?

I work to create a company profile that has hundreds of blogs page. in nextjs I use ISR and the router is " Catch All router " which means I will create all pages & Blog in 1 file page / [[...path.js]] . and I use Revalidate 1 second to update the website.

my question is it doesn't matter if I use Revalidate value is 1 second in production to build the whole page? is it the bad practice? but so far not a problem with 1s revalidate in production.

It's okay to set it to a number that makes sense for your use. Monitor your bill and impact on resources - make the decision based on facts. Generally speaking, blogs don't require near real-time updates - but if there is negligible impact on the bottom line - it doesn't matter.

Just know that if your site gets decent traffic, you will never stop busting cache and rebuilding pages/cache (making a lot of requests) if you have it at one second. However, this approach could be more cost effective than 1 request per user (SSR).

Objectively speaking, a few hundred pages could also build in around two to three minutes via a webhook, realistically, SSG could still be a valid option.

Here is arecap of the ISR process with a revalidation time of 1 second.

  1. Next.js can define a revalidation time per-page (eg 1 second).
  2. The initial request to the product page will show the cached page.
  3. The data for the blog post is updated in the CMS.
  4. Any requests to the page after the initial request and before the 1 second window will show the cached (stale) page.
  5. After the 1 second window, the next request will still show the cached (stale) page. Next.js triggers a regeneration of the page in the background.
  6. Once the page has been successfully generated, Next.js will invalidate the cache and show the updated product page. If the background regeneration fails, the old page remains unaltered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM