Skip to main content
Revalidation is the process of updating cached data. It lets you keep serving fast, cached responses while ensuring content stays fresh.
This page covers revalidation with Cache Components (cacheComponents: true). For the previous model, see the Caching and Revalidating (Previous Model) guide.
There are two strategies:
  • Time-based revalidation: Automatically refresh cached data after a set duration using cacheLife
  • On-demand revalidation: Manually invalidate cached data after a mutation using revalidateTag, updateTag, or revalidatePath

Time-based revalidation with cacheLife

cacheLife controls how long cached data remains valid. Use it inside a use cache scope:
cacheLife accepts a profile name or a custom object with stale, revalidate, and expire fields:
See the cacheLife profiles table for all built-in profile values.
A cache is considered “short-lived” when it uses the seconds profile, revalidate: 0, or expire under 5 minutes. Short-lived caches are automatically excluded from prerenders.

On-demand revalidation

cacheTag

Tag cached data so it can be invalidated on-demand:
Multiple functions can share the same tag. Invalidating the tag revalidates all of them at once.

revalidateTag

revalidateTag invalidates cache entries by tag using stale-while-revalidate semantics — stale content is served immediately while fresh content loads in the background. Ideal when a slight delay in updates is acceptable:
Call revalidateTag in a Server Action or Route Handler. The second argument sets how long stale content can be served while fresh content generates in the background. Using 'max' gives the longest stale window.

updateTag

updateTag immediately expires cached data for read-your-own-writes scenarios — the user sees their change right away instead of stale content. Can only be used in Server Actions:

revalidatePath

revalidatePath invalidates all cached data for a specific route path:
Prefer tag-based revalidation (revalidateTag/updateTag) over path-based when possible — it’s more precise and avoids over-invalidating.

Comparing the APIs

What to cache

Cache data that:
  • Doesn’t depend on runtime data (cookies, headers, search params)
  • You’re OK serving from cache for a period of time
For content management systems, use tags with longer cache durations and rely on revalidateTag to refresh content when it actually changes, rather than expiring the cache preemptively.

Example: Blog with on-demand revalidation