How does Next.js caching work in the App Router?
Why Interviewers Ask This
This question targets practical, hands-on experience with Next.js. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.
Answer
Next.js App Router has a multi-layer caching system: 1. Request Memoization (in-memory, per-render): React deduplicates identical fetch() calls made during a single render tree traversal. If two Server Components call fetch("/api/user"), only one HTTP request is made. Duration: single server request, then cleared. 2. Data Cache (persistent, server-side): Next.js extends fetch with a server-side data cache. fetch("...", { cache: "force-cache" }) caches the response across requests and deployments until manually revalidated. { cache: "no-store" } skips cache. { next: { revalidate: 60 } } revalidates every 60 seconds. Cache persisted across requests, shared between users. 3. Full Route Cache (server-side, static): statically rendered routes are cached as HTML+RSC payload on the server at build time (or at first request). Persists across deployments if not revalidated. 4. Router Cache (client-side): the client stores visited route segments in memory. Avoids re-fetching Server Component data when navigating back. Duration: 30 seconds for pages, 5 minutes for layouts (default, configurable). Opting out: export const dynamic = "force-dynamic" — makes route fully dynamic. noStore() from next/cache — opt a data fetch out of cache. Revalidating: revalidatePath("/blog") or revalidateTag("posts") in Server Actions or Route Handlers. cookies() and headers(): using these functions in a Server Component automatically opts it into dynamic rendering (can't be cached since they depend on the request).
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.
Previous
What is Partial Prerendering (PPR) in Next.js?
Next
What are Server Components vs Client Components trade-offs?
More Next.js Questions
View all →- Intermediate What are Server Components vs Client Components trade-offs?
- Intermediate What is React Suspense and streaming in Next.js?
- Intermediate How do you implement authentication in Next.js?
- Intermediate What is Next.js App Router data fetching patterns?
- Intermediate What is the Next.js App Router folder structure and special files?