Skip to main content
revalidateTag lets you invalidate cached data on-demand for a specific cache tag. It can be called in Server Functions and Route Handlers only — not in Client Components or middleware.

Parameters

string
required
The cache tag to invalidate. Must not exceed 256 characters. Case-sensitive.
string | { expire?: number }
Specifies the revalidation behavior:
  • 'max' (recommended) — Marks the tag as stale and uses stale-while-revalidate semantics. Fresh data is fetched in the background on next visit.
  • Custom cache life profile — Any profile defined in your cacheLife config.
  • { expire: 0 } — Expires the tag immediately (use only when external systems require it, such as webhooks).
  • No second argument — Deprecated. Immediately expires the tag. Migrate to 'max' or updateTag.

Returns

revalidateTag returns void.

Tagging data

Before calling revalidateTag, data must be tagged:

Good to know

  • With profile="max", revalidation is triggered only when a page using that tag is next visited — calling revalidateTag does not immediately re-render pages.
  • The single-argument form revalidateTag(tag) is deprecated. Use the two-argument signature.
  • Use updateTag in Server Actions for immediate cache expiration instead of { expire: 0 }.

Relationship with revalidatePath

They are often used together to ensure comprehensive data consistency:

Examples

In a Server Action

app/actions.ts

In a Route Handler

app/api/revalidate/route.ts

Immediate expiration (webhooks)

For external services that require immediate expiration:
app/api/webhook/route.ts