Next.js caching is the reason two developers can look at the same app and disagree about whether it is fast or broken. One sees instant page loads; the other sees yesterday’s data on a page they just updated. Both are right, because Next.js does not have one cache. It has several, each with its own lifetime and its own way of being cleared, and the defaults changed twice in two major versions. This guide gives you the full mental model for 2026: the four classic layers, what Next.js 15 changed, and how Cache Components in Next.js 16.4 replace the old inheritance model with explicit, opt-in caching.
If you have ever deployed a fix, reloaded the page, and seen the old version staring back at you, this post is for you. By the end you will know which layer was responsible, which API clears it, and which caching pattern to reach for on a real app.
Next.js caching: the four layers at a glance
Forget the idea of “the cache” for a moment. In the classic App Router model, four layers sit between your database and the user’s screen. A request passes through them in order, and each one can serve the response without touching the layers behind it:
| Layer | What it stores | Where it lives | How long it lasts | How you clear it |
|---|---|---|---|---|
| Request memoization | Results of identical data fetches during one render | Server memory | One render pass | Nothing: it ends with the request |
| Data Cache | Fetch responses | Server, persistent | Until revalidated | revalidateTag, revalidatePath, time-based revalidate |
| Full Route Cache | Rendered HTML plus the React Server Component payload | Server | Until revalidated or redeployed | Revalidating the data it depends on, or a redeploy |
| Router Cache | RSC payloads of visited and prefetched routes | Browser memory | The session, within stale-time limits | router.refresh(), Server Actions that revalidate, full reload |
Most stale-data bugs are layer confusion. You cleared the Data Cache but the user still sees the old page because the Full Route Cache still holds the rendered HTML, or because their browser’s Router Cache still holds the payload from their last visit. When a page looks stale, work outward from the data: which layer could still be holding it?
Layer 1: Request memoization (one render, one fetch)
Request memoization is the smallest and least surprising layer. During a single render, if two components call the same fetch() with the same URL and options, React runs the network request once and hands the result to both. Your header, sidebar, and page body can each ask for the current user without tripling your database load, and you do not have to drill props through the tree to achieve it.
Three limits matter. First, it only covers fetch() GET requests; a database query or an Axios call is not deduplicated automatically. For those, wrap the function with React’s cache() helper and you get the same per-render deduplication. Second, it dies with the render: the next request starts from scratch. Third, it never makes data stale across requests, because it never survives one. If your data is wrong for exactly one page load and then fixes itself, memoization was never the suspect.
import { cache } from 'react'
// Without this wrapper, three components calling getUser('123')
// would run three database queries in one render.
export const getUser = cache(async (id: string) => {
return db.users.findUnique({ where: { id } })
})
Layer 2: The Data Cache (fetch results that outlive a request)
The Data Cache is the server-side, persistent store of fetch() responses. In Next.js 14, fetch() in Server Components was cached by default, which is why so many developers shipped apps that served yesterday’s API data and could not work out why. Next.js 15 flipped the default: fetch() requests are now uncached unless you opt in. That single change ended the most common class of “my data isn’t updating” bugs, and it is the first thing to check when you copy caching code from an old tutorial.
To opt a fetch into the Data Cache in the 15/16 default model, you choose a lifetime:
// Never cached: fresh on every request (the 15+ default)
const live = await fetch('https://api.example.com/live', {
cache: 'no-store',
})
// Cached until you invalidate it by tag
const post = await fetch(`https://api.example.com/posts/${id}`, {
next: { tags: [`post-${id}`, 'posts'] },
})
// Cached for 60 seconds, then revalidated in the background
const prices = await fetch('https://api.example.com/prices', {
next: { revalidate: 60 },
})
Tags are the important habit here. A bare time window is fine for prices, but content that changes when someone publishes needs a tag: tag the fetch when you read it, then call revalidateTag() from the publish webhook or Server Action that writes it. Time-based revalidation guesses when data changed; tags know.
Layer 3: The Full Route Cache (the whole rendered page)
The Full Route Cache stores the finished product: the rendered HTML and the RSC payload for a route. When a request hits a cached route, Next.js serves it without rendering anything or touching your database, which is why static pages feel instant. A route lands in this cache when it has no dynamic behaviour: no cookies, headers, or search params read during render, and no uncached data.
The moment a route reads request-time data, it opts out of this layer. That is why adding a personalised greeting to a marketing page can quietly turn the whole page dynamic, and why the fix is usually to split the page: keep the static shell static and stream the personalised part inside a <Suspense> boundary. The route-level switches still work in the default model:
// Force the whole segment to render fresh on every request
export const dynamic = 'force-dynamic'
// Or cache it and revalidate on a schedule (ISR)
export const revalidate = 3600
Check what actually happened with next build: static routes are marked with a filled circle, dynamic routes with a lambda symbol, and ISR routes with a half-filled circle. If the symbol does not match your intention, something in the tree is reading dynamic data that you did not expect, and the build output tells you where to look.
Layer 4: The Router Cache (why the back button lies to you)
The Router Cache lives in the browser. When a user navigates with <Link>, Next.js prefetches route segments and keeps their RSC payloads in memory, so back/forward navigation and repeat visits feel instant without another server round trip. This is the layer behind the most confusing bug of all: you fixed the server, revalidated everything, and the user still sees the old page, because their browser never asked the server again.
The defaults here changed too. In Next.js 15 and later, dynamic pages have a stale time of 0 seconds, meaning repeat navigation refetches from the server, while static pages keep a 300-second (5-minute) stale window. You can tune both with experimental.staleTimes in your Next.js config, but think twice before raising the dynamic value: every second you add is a second in which a user can navigate back to data you have already invalidated on the server.
// next.config.ts
const nextConfig = {
experimental: {
staleTimes: {
dynamic: 30, // seconds before a dynamic route refetches
static: 180, // seconds before a static route refetches
},
},
}
When a mutation should be visible immediately, invalidate from the client side too: router.refresh() re-fetches the current route, and Server Actions that call revalidatePath() or revalidateTag() clear the matching Router Cache entries as part of the action. If you only revalidate on the server and never refresh the client, the user staring at the page will not see the change until they navigate away and back.
Next.js caching in 16.4: Cache Components change the model
Here is where the old four-layer story stops being the whole story. Across the 16.x releases, Next.js introduced Cache Components, a new programming model in which caching is explicit and opt-in at the level of a function, component, or route. In Next.js 16.4, released on 6 October 2026, the Next.js team recommended Cache Components as the best choice for every app, enabled it by default for new apps created with create-next-app, and announced it will become the default for all apps in Next.js 17. Existing apps keep the old model until you opt in, so upgrading to 16.4 does not silently change your caching behaviour.
Opting in takes two config flags, and then the directive does the work:
// next.config.ts
const nextConfig = {
cacheComponents: true,
partialPrefetching: true,
}
// Cache a whole page's data explicitly
'use cache'
import { cacheLife, cacheTag } from 'next/cache'
export default async function ProductPage({ params }) {
cacheLife('hours')
cacheTag(`product-${params.id}`)
const product = await db.products.findById(params.id)
return <ProductView product={product} />
}
Notice what disappeared: no segment config inherited from three layouts up, no fetch silently cached because of a default you forgot. Everything else runs at request time by default, and the cached parts form a static shell that streams alongside dynamic regions inside <Suspense> boundaries. That is also what finally makes Partial Prerendering practical for ordinary apps: a blog post renders once and serves instantly, while the reader’s avatar streams in fresh beside it.
cacheLife: how long an entry lives
cacheLife() sets three numbers for a cached entry: how long it is fresh (stale), how often it revalidates in the background (revalidate), and when it expires outright (expire). Next.js ships built-in profiles, and you can define your own in next.config.ts:
| Profile | Stale | Revalidate | Expire |
|---|---|---|---|
| ‘seconds’ | 0s | 1s | 60s |
| ‘minutes’ | 5 min | 1 min | 1 hour |
| ‘hours’ | 5 min | 1 hour | 24 hours |
| ‘days’ | 5 min | 1 day | 14 days |
| ‘weeks’ | 5 min | 1 week | 30 days |
| ‘max’ | 5 min | 30 days | 365 days |
Pick the profile from the data, not from habit. Product descriptions get 'days'; a dashboard stat gets 'minutes' or nothing at all. The most common Cache Components mistake is the same as the old one: reaching for 'max' because it feels fast, then discovering that “fast” and “stale for a year” are the same thing.
Invalidation in the Cache Components model
Tags still do the targeted work, but the APIs split into two distinct jobs. revalidateTag() marks a tag stale and serves the old value while it refreshes in the background; in the Cache Components model it takes a cacheLife profile as its second argument to describe that stale-while-revalidate behaviour. updateTag() is the newer, sharper tool: it is Server Actions only, and it expires the tag and refreshes it immediately within the same request, giving you read-your-writes semantics. After a user submits a form, updateTag() means they see their change on the very next render, with no reload and no stale flash.
'use server'
import { updateTag } from 'next/cache'
export async function updateProfile(userId: string, data: ProfileData) {
await db.users.update({ where: { id: userId }, data })
// The user sees the new profile immediately, in this same request.
updateTag(`user-${userId}`)
}
Two more 16.4 additions are worth knowing. 'use cache: private' scopes a cached entry to a single browser, for data that must never be shared across users, and 'use cache: remote' pairs with a cache handler when you need entries shared across many server instances. And ensureStatic, a route segment export, fails your build if dynamic content sneaks into a route you meant to be static: a tripwire for the exact class of accident that used to ship silently.
Which pattern for which data?
When you are deciding, start from the data’s freshness requirement, not from the API you like most:
| Data | Pattern |
|---|---|
| User-specific dashboard, profile, cart | No cache: default request-time rendering, or 'use cache: private' where it fits |
| Blog posts, docs, marketing pages | 'use cache' + cacheLife('days') + cacheTag, invalidated on publish |
| Content that changes on a schedule | cacheLife('hours') or time-based revalidate in the default model |
| Real-time prices, inventory, live scores | cache: 'no-store', plus client polling or a websocket for updates |
| Form submissions the user must see instantly | Server Action + updateTag() |
| CMS or payment webhooks | Route Handler + revalidateTag() |
One more rule that saves more debugging sessions than any other: never cache something that reads cookies, headers, or the current user inside the cached scope. Read request-time values outside the cached function or component and pass them in as arguments. A cached entry is shared, and the moment it captures one user’s identity, every user after them gets that identity’s data.
Five mistakes that cause every stale-data ticket
1. Copying version 14 code into a version 15+ app. The old tutorials assume fetch() is cached by default. In 15 and 16 it is not, so the old code under-caches, and the old workarounds (sprinkling no-store everywhere) actively fight the new model. Check the version before you copy a snippet, every time.
2. Clearing the server cache but not the Router Cache. Your revalidatePath() worked; the user’s browser simply never asked again. Pair server invalidation with router.refresh() or a Server Action so the client drops its payload too.
3. Caching a page that reads the user. If a cached component calls cookies() or reads the session, the first visitor’s data becomes everyone’s data. Move the read outside the cache boundary and pass the value in.
4. Using one tag for everything. A single 'posts' tag means publishing one post invalidates every post. Tag per entity (post-42) plus a collection tag ('posts') and invalidate the narrow one when you can.
5. Testing caching in development. Dev mode does not behave like production: the dev server revalidates aggressively and the build output that tells you what is static never runs. Test caching behaviour with next build && next start, not with the dev server, and read the route symbols in the build output.
Your migration path, if you are still on the old model
If your app runs Next.js 16 in the default model, you do not have to migrate everything at once, and you should not. Upgrade to 16.4, enable cacheComponents on a staging branch, and convert one route at a time, starting with the most static one: a blog post page or a marketing page where the win is obvious and the blast radius is small. Keep the old route configs on the routes you have not converted yet; the two models coexist while you move across. The expensive mistake is waiting until Next.js 17 makes the new model the default and migrating under release pressure, which is exactly when the “which layer is stale” debugging sessions happen.
Next.js caching stops being confusing the moment you stop treating it as one cache and start naming the layer. Memoization deduplicates a render. The Data Cache persists a fetch. The Full Route Cache serves a finished page. The Router Cache serves a previous visit. And in 16.4, Cache Components let you say, in the code itself, which of those things you actually want.
Further Reading & References
- Next.js 16.4 — Cache Components recommended for every app (official release post, 6 October 2026)
- Next.js 16.4 Cache Components: A Migration Guide for Existing Apps
- Next.js use cache Explained: Cache Components, cacheLife and cacheTag in Next.js 16.4
- Next.js Caching Mental Model in 2026: Request Memoization, Data Cache, Full Route Cache, and Router Cache
- Next.js Cache Systems
- X-Nextjs-Stale-Time: the Router Cache stale-time header (default 300s static, 0s dynamic)
- Next.js Route Handlers: GET Stopped Caching in 15 — How to Cache in 16
- Next.js Caching Explained: Every Strategy You Need to Know
- Next.js Middleware in 2026: The Complete Guide (It’s Called Proxy Now) — HowToShipIt
- Upgrade Next.js 15 to 16: The EOL Checklist That Won’t Break Your Build — HowToShipIt
Published 27 October 2026. All framework facts verified against the official Next.js 16.4 release post and current Next.js caching guides on 27 October 2026.



