Question presented to candidate: "Next.js has several caches that interact. Name them, tell me where each lives and how long it lasts, and how you invalidate each one."
What a strong answer should cover:
- Request Memoization: identical fetch GETs within one server render run once; lives for one request.
- Data Cache: fetch results opted in with
force-cacheorrevalidate, persisted across requests and deployments until revalidated. - Full Route Cache: the HTML and RSC payload of static routes, produced at build time or revalidation.
- Router Cache (now called the Client Cache): RSC payloads kept in the browser memory for back and forward navigation and prefetched routes.
- Invalidation:
revalidatePath,revalidateTag, time-basedrevalidate, androuter.refresh()for the client side; Next.js 16 docs label this four-cache model the "previous model", superseded by Cache Components.
Clarifying questions expected:
- "Is Cache Components enabled?" β with it, caching is opt-in with 'use cache' and the old layer names mostly disappear.
- "Where is the stale data showing up: first load or client navigation?" β it points to a different layer.
Code / implementation expected: Optional β a fetch that touches each layer, and the calls that clear them.