Caching in Next.js 16 · senior
ISR and rendering a large catalog
For tens of thousands of product pages, prerender only the popular ones with generateStaticParams, serve an instant App Shell for the rest and upgrade them after the first visit (16.3+), split each page by how often data changes, and invalidate with tags when prices change.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
generateStaticParamslists params to prerender at build (top sellers); prerendering everything costs build time and storage for pages nobody visits.- Cache Components + Partial Prefetching (16.3+): unlisted URLs get the App Shell instantly; Next.js renders the concrete page in the background and caches it for the next visitor. Await
paramsinside Suspense for this. - Without Partial Prefetching (or with
ensureStatic = "navigation"), the first request for an unlisted path waits for the complete page (likefallback: "blocking"). - A default
<Link>prefetches only the App Shell; product links needprefetch={true}to prefetch URL-specific cached content. - Split by volatility: product details
"use cache"+cacheLife("days")+cacheTag("product-42"); price with a short lifetime or streamed per request behind Suspense; stock and personalisation at request time. - On price change:
updateTagin the admin Server Action, orrevalidateTag(tag, "max")from a webhook. Never a full rebuild. - Previous model:
export const revalidate = 3600orfetch(..., { next: { revalidate } });dynamicParams = falsereturns 404 for unknown params. - SEO: metadata in the shell for most pages; crawlers that need full HTML get a blocking render.
The red pen
Common traps: mistake → fix
Mistake: "SSR all 40,000 pages on every request"
Fix: expensive and slower than cached shells.
Mistake: "Rebuild the site when a price changes"
Fix: use tag invalidation.
Mistake: "Prerender every product at build"
Fix: long builds for pages that may never be visited.
Easy to hard
Questions interviewers ask, easy to hard
- We have 40,000 product pages, prices change every few minutes, and pages must be fast and crawlable. How do you render them in Next.js 16?
- Which pages do you prerender at build?
- What does the first visitor to an unprerendered product see?
- How do you keep prices fresh?
- What changes for personalised blocks?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.