Hi all,
My understanding of ISR in Next.js is: If ISR fails on second revalidation (for example: external API is down), it will fallback to the previously successful generated content from the first revalidation.
Does that currently work with Next.js on Netlify?
Thanks very much.
Hey @sevfurneaux ,
Yes, Netlify uses Stale While Revalidate (SWR). So it will continue to serve the previous content as long as the fresh one is not available.
The readme offers better description that that PR (this document is linked in the top-readme):
## Incremental Static Regeneration (ISR)
[Incremental static regeneration](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration) is a feature
of Next.js that allows pages to be updated after a site has been built and deployed. It is now fully supported in
Netlify by the Next Runtime, meaning large sites can update pages without needing to rebuild the entire site. Unlike
server-side rendered pages, the page is not rebuilt for each user, so they load quickly, but unlike statically-generated
pages they can be periodically updated with new content without a new deploy.
### Using ISR on Netlify
ISR on Netlify is implemented with [On Demand Builders](https://docs.netlify.com/configure-builds/on-demand-builders/),
using the TTL feature. You can enable ISR for a page by returning a value for `revalidate` from the `getStaticProps`
function. This value is the number of seconds for which the content will be considered fresh. If a request arrives for a
page after the `revalidate` period has elapsed, the page will be regenerated. ISR uses a "stale while revalidate"
strategy, meaning that the visitor still receives the stale content, but it is regenerated in the background ready for
the next request. The generated page is persisted globally, so is available to all visitors wherever they are in the
world. It is also cached in the global Netlify CDN so responses are fast.
The minimum value for `revalidate` is 60 seconds, and any value less than that will be rounded-up to 60 seconds. After a
request is made for stale content, the page will be regenerated in the background and immediately persisted globally,
This file has been truncated. show original
Thanks for the info.
Does that mean On Demand Builders will continue to serve stale content once the TTL has expired if there is an error on regeneraiton?
Yes, as long as the page generation is not successful, the cached copy will be served.
Great, thanks for the info @hrishikesh !