Next.js has four caching layers. Understanding each one prevents stale data bugs and unnecessary re-fetching.
1. Request Memoization
Where: Server, during a single render pass
What: Deduplicates identical fetch() calls within the same request.
// Both calls in the same render hit the network only onceconst posts1 = await fetch("/api/posts");const posts2 = await fetch("/api/posts"); // memoized
Applies only to GET requests in fetch()
Scoped to the React Component tree render
Cannot be opted out of — it's automatic
Does NOT apply to Route Handlers or non-fetch data calls
2. Data Cache
Where: Server, persistent across requests and deployments
What: Caches the result of fetch() calls.