Skip to content
Sandeep Kumar
Updated 5 min read

Next.js App Router caching: the four caches explained

Caching in the App Router is opt-in since Next.js 15, which inverts guides written for 14. The four caches, what makes a route dynamic, and Cache Components.

Sandeep Kumar, Full-stack EngineerSandeep KumarFull-stack Engineer
Next.js App Router caching: the four caches explained: Where a request can be answered before it reaches your data
On this page
  1. 1. Caching is opt-in since Next.js 15
  2. 2. Four caches, and only two need you
  3. 3. Find out why a route went static
  4. 4. Use Cache Components in Next.js 16
  5. 5. Ask two questions per route
  6. Conclusion

Is your Next.js data stale, or worse, showing up on someone else's screen? Since Next.js 15, fetch is not cached unless you opt in, and only two of the App Router's four caches are yours to tune.

Most guides still teach the Next.js 14 model, where everything was cached by default.

Say you're Anika, and a support email lands on a Friday evening: "Why does my dashboard greet me by someone else's name?" One user's page is reaching another, and nothing tells you which cache is doing it.

This post is the map:

  • what changed in 15
  • the four caches in the order a request meets them
  • why a route goes static
  • the explicit model Next.js 16 adds

1. Caching is opt-in since Next.js 15

In Next.js 14, fetch was cached unless you opted out. That is where years of "why is my data stale?" came from.

Since Next.js 15 the default is auto no cache. The official docs say it plainly: caching is opt-in, and you set cache: 'force-cache' to cache a request.

If you learned this on 14 and have not looked since, your mental model is inverted. Every tutorial from 2023 will quietly push you the wrong way, and I think that is the single biggest source of caching confusion I see.

app/page.tsxts
// Not cached. This is the default in 15 and 16.
const live = await fetch(url);

// Cached until you say otherwise
const posts = await fetch(url, { cache: 'force-cache' });

// Cached with a lifetime (the old ISR behaviour)
const feed = await fetch(url, { next: { revalidate: 60 } });

// Cached, invalidated by event
const post = await fetch(url, { next: { tags: ['post'] } });
app/actions.tsts
'use server';
import { updateTag } from 'next/cache';

export async function updatePost() {
  // ...write to your CMS/db...
  updateTag('post'); // Next 16: expire the tag now, and let this action read its own write
}

Next.js 16 moved the furniture here. revalidateTag now takes a second argument, a cacheLife profile such as 'max' or { expire }. It marks data stale for the next request rather than purging it on the spot.

For a server action that has just written something and needs the next read to see it, updateTag is the one you want. On Next 15, the single-argument revalidateTag('post') still works.

Version Default for fetch Invalidate a tag
14 cached revalidateTag(tag)
15 not cached revalidateTag(tag)
16 not cached updateTag(tag) in actions, revalidateTag(tag, profile) elsewhere

One detail catches people: { revalidate: 3600, cache: 'no-store' } is a contradiction. Next.js ignores both options and warns in dev, so more cache options do not make something more cached.

2. Four caches, and only two need you

A request passes through up to four layers before it reaches your database. Seeing them in order makes it obvious where a stale or leaked page can come from.

  1. 1Router Cacheclient side, back and forward navigation
  2. 2Full Route Cacheprerendered HTML and RSC payload
  3. 3Request memoizationdedupes identical GET fetches in one render
  4. 4Data Cachefetch results, kept until revalidated
  5. 5Your API or databaseonly reached on a miss
Where a request can be answered before it reaches your data
  • Request memoization runs the same fetch once per render, so calling it in a layout and a page costs one request. It is automatic and not configurable beyond an AbortController signal. You will never tune it.
  • The Data Cache is the one from section 1, and the only one I tune on purpose. It persists across requests and deploys until something revalidates it.
  • The Full Route Cache holds the rendered output of statically prerendered routes.
  • The Router Cache makes client navigation instant.

The last two mostly manage themselves. When they surprise you, it is almost always because a route you thought was static reads something at request time, or the reverse.

3. Find out why a route went static

A route prerenders unless something forces it not to. Reading cookies(), headers() or searchParams does it. So does cache: 'no-store'.

app/dashboard/page.tsxts
export const dynamic = 'force-dynamic'; // never prerender
// or
export const revalidate = 30;           // revalidate the whole route

Here's the catch: dynamic is not the same as safe.

Anika's dashboard read the session token from cookies, which made the route dynamic, exactly as it should be. Then it loaded the stats through unstable_cache(() => getStats(token), ['dashboard']).

The token lived in the closure, and closure variables are not part of the cache key. The first user to load the page after each revalidation filled the entry. Everyone after that saw that user's name.

If data is per-user, either keep it out of every cache or put the user in the key. And read the build output (the ○ and ƒ markers) rather than assuming. I check it on every deploy that touches a layout, because one cached helper three components down is enough.

4. Use Cache Components in Next.js 16

Next.js 16 ships Cache Components, enabled with cacheComponents: true in next.config.ts. Everything is dynamic by default. You cache a function or component with:

  • a 'use cache' directive
  • cacheLife() for the lifetime
  • cacheTag() for invalidation
ts
async function getStats() {
  'use cache';
  cacheLife('hours');
  cacheTag('dashboard-stats');
  return db.query(/* … */);
}

It replaces experimental.ppr, and experimental.dynamicIO and experimental.useCache should come out of your config. Next.js prerenders a static shell and streams the dynamic parts, so anything reading cookies, headers or an uncached fetch belongs inside a <Suspense> boundary. I collected the rest of the upgrade notes in Next.js 16 notes.

I like this direction a lot. Inferring cacheability from whether you happened to call cookies() somewhere down the tree was always the confusing part. A directive you can see in the function is hard to get wrong by accident.

5. Ask two questions per route

The mental model fits on an index card, and it has survived every version change so far:

  • How fresh does this have to be? That puts the route on a scale from prerendered, to revalidated, to fully dynamic.
  • What invalidates it: time, or an event?

Answer both and you already know which options to reach for.

The failure I see most is answering neither, getting burned once, and then disabling caching everywhere. It feels safe. It is a real cost, paid on every request, forever, and it shows up later as a slow site and a bigger bill.

Conclusion

Decide per route, not per app: how fresh, and what invalidates it. Then opt in to exactly that much caching, and keep anything per-user out of shared entries or in the key.

Anika's fix took ten minutes once she knew where to look: the user ID in the cache key, and a tag so a write can expire it.

If caching is part of a bigger speed problem, the Next.js performance optimization guide is the next read. For what crawlers see, there is technical SEO for Next.js, and for caching around an LLM, build a RAG chatbot with Next.js.

Which of the four caches has bitten you hardest so far?

FAQs

Is fetch cached by default in the Next.js App Router?

No, not since Next.js 15. The default is `auto no cache`: the resource is fetched on every request in development, and once during next build if the route is statically prerendered. Caching is opt-in: pass cache: 'force-cache' to cache a request, or next: { revalidate: n } to cache it with a lifetime. Next.js 14 cached by default, which is why older guides say the opposite.

What are the four caches in the Next.js App Router?

Request memoization dedupes identical GET fetches within a single render pass and is not configurable. The Data Cache persists fetch results across requests and deploys until revalidated, and is the one you reach for. The Full Route Cache holds the rendered HTML and RSC payload of prerendered routes. The Router Cache is client-side, for instant back and forward navigation. In practice you tune the Data Cache and leave the rest alone.

Why is my Next.js data stale after a write?

Something is caching it and nothing is invalidating it. Either a fetch opted in with force-cache or a revalidate interval, or a route-level `export const revalidate`. Call revalidateTag or revalidatePath in the server action that performs the write. Note that conflicting options such as { revalidate: 3600, cache: 'no-store' } are ignored entirely, with a warning in development.

What is 'use cache' in Next.js 16?

Cache Components, enabled with cacheComponents: true in next.config.ts. Instead of inferring cacheability from whether you called cookies() somewhere in the tree, you mark a function or component with a 'use cache' directive, set its lifetime with cacheLife() and its invalidation key with cacheTag(). It replaces experimental.ppr, and experimental.dynamicIO and experimental.useCache should be removed from your config. Dynamic reads belong inside a Suspense boundary.

Does Next.js caching behave differently in development?

Yes, and it will mislead you. Development keeps an HMR cache that applies even to uncached fetches, so no-store requests may not show fresh data between hot reloads, though it clears on navigation or a full reload. A hard refresh sending cache-control: no-cache causes the cache, revalidate and tags options to be ignored entirely. Always verify caching against next build && next start.

Found this useful?Share on XShare on LinkedIn

Related reading