Refresh published content
A blog post or documentation page changes and a small delay before fresh content appears is acceptable.
Next.js 16+ · Function
Invalidates cached data associated with a tag using stale-while-revalidate behavior. In Next.js 16, pass a cacheLife profile such as "max" as the second argument.
Call revalidateTag from server-side code with a cache tag and a revalidation profile. It marks matching cached data stale, then the next request serves stale content while revalidation runs; after the profile's allowed stale period, a request waits for fresh data.
revalidateTag(tag: string, profile: string | { expire?: number }): void;| Name | Type | Description |
|---|---|---|
tag | string | Cache tag associated with the cached data to invalidate. It is case-sensitive and limited to 256 characters. |
profile | string | { expire?: number } | Controls how long stale content may be served. Use "max", another cacheLife profile, or an object with an expiration in seconds. |
void
max profile provides stale-while-revalidate behavior for a long stale window.{ expire: 3600 }.updateTag in a Server Action when read-your-writes or immediate expiration is required.import { revalidateTag } from 'next/cache'
export async function POST() {
// Update the data source here.
revalidateTag('articles', 'max')
return Response.json({ revalidated: true })
}This Route Handler marks cached entries tagged articles as stale; the next request receives stale data while fresh data is generated.
A blog post or documentation page changes and a small delay before fresh content appears is acceptable.
Several cached functions share one tag and should be invalidated together.
A Route Handler receives a webhook from a content or product system.
cacheLiferevalidatePathupdateTag