Next.js
/Intermediate
Revalidation
Definition
The process of purging the Next.js Data Cache and re-fetching fresh data.
Explain Like I'm New
Next.js caches your fetch requests to make your site fast. But if you update a blog post, the cache is now wrong. Revalidation is how you tell Next.js: 'Hey, throw away that old cached version and grab the new one.'
Real World Example
Time-based: Revalidating a 'Live Weather' API every 60 seconds. On-demand: Revalidating the 'Products' page the exact millisecond an admin clicks 'Save' in the CMS.
Common Use Cases
- •Keeping cached data fresh
- •CMS webhooks
- •ISR (Incremental Static Regeneration)
Interactive Example
Loading Code Playground...
Interview Questions
basic
- What are the two main types of revalidation in Next.js?
intermediate
- If you set `revalidate: 3600`, how often does the data refresh?