Under The Hood
frontend nextjs Next.js 14+/15 App Router

Next.js App Router: the caching layers

Last updated
Prerequisites:
Next.js App Router basics
Familiarity with fetch and cache-control semantics
  • nextjs
  • caching
  • app-router
  • cache
  • revalidation
  • ssg

Read at your depth

The practical view

The App Router has several caches with distinct lifetimes: the full route cache (prerendered HTML stored on the server/CDN, revalidated by revalidatePath/time-based revalidate); the data cache (persisted fetch() results keyed by URL + options, controlled by next: { revalidate } or fetch's cache); the router cache (client-side cache of visited segments and prefetched payloads, invalidated on navigation to stale-while-revalidate pages); and React's request memoization (dedupes identical fetches within one render pass, always fresh within the request). The practical rule: add noStore()/no-store to anything user-specific, use revalidateTag('x') after mutations, and remember the router cache is per-session on the client.

The same idea in other frameworks

react equivalent
// React 19: <Cache> component, cache() for memoization;
// framework (Next) owns fetch caching and hydration

Legacy vs modern

Stale user data vs correctly revalidated data

A default fetch caches aggressively and can leak cross-user data; opting the route out and tagging mutations keeps data both fast and correct.

before → after
Uncontrolled default caching
const res = await fetch('https://api.example.com/me');
const me = await res.json();
Explicit cache strategy
const res = await fetch('https://api.example.com/me', { next: { revalidate: 60 } });

Interview gotchas

Under The Hood — a multi-depth technical interview hub.

Press ⌘ K to search.