- All Courses
- Next.js for Production
- Data Fetching and Caching
- Revalidation: time-based and on-demand
Revalidation: time-based and on-demand
Time-based revalidation serves the cached response and refreshes it in the background once the window has passed.
Overview
Stale content, on a schedule you choose
Time-based revalidation serves the cached response and refreshes it in the background once the window has passed. The first visitor after expiry still gets a fast response — they just get the previous one.
On-demand revalidation is the precise tool: when an editor publishes, the publishing system tells your app exactly what changed and only that content is dropped from the cache. Invalidating by tag is usually easier to reason about than by path, because one tag can cover every page that uses a piece of content.
The two combine well. A generous time window is your safety net for changes the webhook missed, and the webhook keeps the common case immediate.
In this lesson you will:
- Choose a revalidation window that matches the content
- Invalidate by tag when content changes
- Wire a CMS webhook to a revalidation route
Resources
Notes are not saved yet — they clear when you leave this page.
Request memoization and the data cache
6m
Streaming with Suspense boundaries
26m