What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
In the current Next.js Cache Components model, tag the cached data with cacheTag inside a use cache scope, then call revalidateTag(tag, 'max') after the underlying data change succeeds. That marks matching entries stale; a later request can receive stale content while Next.js refreshes it in the background. On a multi-instance self-hosted deployment, you must also coordinate both cached data and tag invalidation state across instances—a shared data store alone does not make invalidation propagate.
Choose the invalidation behavior before choosing the API
These APIs solve related but distinct problems. Choose based on how quickly the reader must see a change, where the invalidation runs, and whether the target is data or a route.
As an Amazon Associate I earn from qualifying purchases.
| Need | API | Behavior and boundary |
|---|---|---|
| Refresh in the background; brief staleness is acceptable | revalidateTag |
With the current Cache Components API, revalidateTag(tag, 'max') uses stale-while-revalidate: stale data may be served while the cache refreshes. It is supported in Server Actions and Route Handlers. |
| The user must immediately see their own successful change | updateTag |
Immediately expires tagged cache data for read-your-own-writes behavior. It is available in Server Actions only. |
| Invalidate by route rather than by knowing which data tags a route uses | revalidatePath |
Targets a route path. It is a different invalidation scope from a data tag. |
For ordinary edits where a short-lived stale view is acceptable, revalidateTag(tag, 'max') avoids making the mutation wait for every dependent cache entry to be rebuilt. If the action’s next rendered result must reflect the write immediately, use updateTag from that Server Action instead. Prefer a data tag when the changed record is consumed in several places; use a path when the route itself is the scope you need to invalidate.
The current Next.js revalidation guide, updated March 3, 2026, describes Cache Components behavior and directs users of the previous caching model to its separate guide. The current API references for revalidateTag, updateTag, and cacheTag were updated February 27, 2026. Match examples to your installed Next.js version and cache model rather than combining signatures from different documentation generations.
#1 Best Overall
Tag the cached unit that should become stale
For Cache Components, enable cacheComponents, then attach a stable tag inside the cached function or component using cacheTag. Tag the cached value that depends on the changed record—not every page that might display it. Multiple cached functions can share a tag, so one invalidation can mark all of those entries stale.
import { cacheTag } from 'next/cache'
async function getProduct(id) {
'use cache'
cacheTag(`product:${id}`)
return db.product.findUnique({ where: { id } })
}
Choose tag names that identify the data dependency, such as product:123, rather than a URL that happens to display it. If a product detail view and a product summary both cache the same record independently, give both cached units the same tag when both should be invalidated by an edit. A tag can also represent a collection, such as products, when a mutation changes data used by a cached listing. Use a narrow record tag for record-specific edits and a broader collection tag only when the collection’s cached results really depend on the change.
Current cacheTag documentation sets a maximum of 256 characters per custom tag and 128 tag items. Tags are identifiers, not a substitute for designing cache boundaries: tagging a very broad set may invalidate more cached work than the mutation requires.
Rank #2
Invalidate after the mutation succeeds
In a Server Action, perform the database write first. Only after it succeeds should you mark dependent cache data stale. The following example uses the current Cache Components API and intentionally chooses stale-while-revalidate:
'use server'
import { revalidateTag } from 'next/cache'
export async function saveProduct(id, changes) {
await db.product.update({ where: { id }, data: changes })
revalidateTag(`product:${id}`, 'max')
}
If the database operation throws, execution never reaches the invalidation call, so a failed write does not cause an unnecessary cache refresh. A Route Handler can also call revalidateTag, for example when a trusted webhook reports that external data has changed; authenticate such endpoints according to the application’s threat model before allowing callers to invalidate tags.
To make a Server Action reflect its own write immediately, replace the stale-while-revalidate choice with updateTag(`product:${id}`). Do not use that as a Route Handler substitute: updateTag is restricted to Server Actions, while revalidateTag supports both call sites.
Rank #3
Do not copy the older single-argument API into current examples
The versioned Next.js 15 reference documents revalidateTag(tag: string): it marks tagged data stale, with regeneration when a page using the tag is next visited. The Next.js 14 reference also documents the single-argument form. Those references belong to earlier API guidance and should not be treated as the current Cache Components signature.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →In the current Cache Components model, use cacheTag within a use cache scope to attach tags, and use revalidateTag(tag, 'max') for the documented stale-while-revalidate profile. Previous-model applications may instead use tagged fetch data and the API context documented for that model. Confirm whether the application uses Pages Router ISR, the previous App Router caching model, or Cache Components before changing code or cache configuration.
Why stale content can appear after revalidation
With the current 'max' profile, seeing the old value immediately after invalidation can be expected: the entry is stale, and the next request may receive it while refresh happens in the background. This favors availability and background regeneration over immediate read-after-write freshness. If the user must see the new value in the Server Action’s result, use updateTag for that flow.
If stale data continues beyond the expected refresh flow, check whether the request is reaching a different self-hosted instance, whether the right cached function has the tag, and whether a CDN or reverse proxy is serving its own cached response. In a multi-instance deployment, invalidating one instance does not automatically invalidate the others by default.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Self-hosted deployments need shared cache and invalidation state
One server with persistent local disk
A single self-hosted Next.js server uses the local filesystem cache by default. This is automatic for a single next start instance when its local disk persists. If the process restarts but the filesystem cache survives, the default storage can remain available; ephemeral storage changes that assumption.
Free tools Windows power users keep installed
One-click scans. No signup required.
Multiple instances or ephemeral compute
For multiple App Router instances, a revalidateTag() call on one instance invalidates that instance’s cache by default. Other instances can continue serving stale entries until they discover the invalidation independently. A common external store for cached values is not, on its own, proof that tag state is synchronized.
The current self-hosting guide calls for implementing refreshTags() in the custom cache handler so tag state is synchronized from shared storage before requests. Design the deployment to coordinate both the cached data and invalidation metadata, and account for the consistency and latency requirements of the application. The guide names Redis and AWS S3 as possible storage destinations; it does not establish one provider as universally preferable.
Use the handler interface for the cache model in use
| Configuration | Cache surface | Documented interface details |
|---|---|---|
cacheHandler (singular) |
Server cache for ISR and Route Handler responses | Can implement get, set, revalidateTag, and resetRequestCache. The documentation identifies it as stable since Next.js 14.1.0. |
cacheHandlers (plural) |
Cache Components, including use cache and use cache: remote |
Its documented interface includes get, refreshTags, getExpiration, and updateTags; entries carry tags and stale, revalidate, and expire timing. use cache: private is not configurable through this option. |
These names are not interchangeable. Do not configure cacheHandler for a Cache Components backend merely because both settings mention cache, or assume cacheHandlers configures every ISR and route-response cache. Identify the cached workload first, then implement the corresponding interface and its invalidation coordination.
Validate invalidation across the actual deployment
Before relying on a custom backend, test the full write-to-read path in an environment that matches the production topology. A useful validation plan is:
- Record the Next.js version and identify whether the relevant data uses Pages Router ISR, the previous App Router model, or Cache Components.
- List the mutation and each cached value that depends on it; confirm the tags are applied to those cached units.
- Choose stale-while-revalidate, immediate expiration, or route invalidation based on the required freshness and call site.
- For one local instance, verify that the filesystem used by the default cache persists across the restarts that matter to your deployment.
- For multiple instances, send a mutation through one instance, then route reads to other instances. Check behavior during regeneration and after tag-state synchronization, including after a restart.
- If a CDN or reverse proxy sits in front of Next.js, verify its cache-control handling and that its cache key varies for every response variant your application serves.
This separates an application-level tag mistake from a deployment-level propagation problem. It also reveals when a browser, proxy, or CDN is returning a response that the Next.js cache handler did not control.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




