Lesson 2.3

Revalidation: time-based and on-demand

Time-based revalidation serves the cached response and refreshes it in the background once the window has passed.

17mIntermediate13.7k students

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

Previous Lesson
Next Lesson
Revalidation: time-based and on-demand — Next.js for Production — Vertex