Next.js & App Router (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How does the Next.js 4-tier Caching Architecture work?
senior LevelMost AskedCode ExampleSystem Design
In Simple Words: Next.js implements four distinct caching mechanisms:
sql
[ 1. Request Memoization ] -> De-duplicates identical GET fetch() calls within ONE render pass (Server in-memory)
|
v
[ 2. Data Cache ] ---------> Persists fetched data across requests and user deployments (Server persistent)
|
v
[ 3. Full Route Cache ] ---> Caches static HTML and RSC payload on the server (Build time / ISR)
|
v
[ 4. Router Cache ] -------> In-memory client-side cache storing RSC payloads during the user session
- Request Memoization: If 3 components on a page call
fetch('https://api.com/user'), Next.js executes the network call only once. - Data Cache: Controls cross-request caching via
fetch(url, { next: { revalidate: 3600 } }). - Full Route Cache: Automatically caches static routes at build time.
- Router Cache: Client-side memory cache that makes navigating between previously visited pages instant.