Skip to the page

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.

The notes

What you must know

  • generateStaticParams lists 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 params inside Suspense for this.
  • Without Partial Prefetching (or with ensureStatic = "navigation"), the first request for an unlisted path waits for the complete page (like fallback: "blocking").
  • A default <Link> prefetches only the App Shell; product links need prefetch={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: updateTag in the admin Server Action, or revalidateTag(tag, "max") from a webhook. Never a full rebuild.
  • Previous model: export const revalidate = 3600 or fetch(..., { next: { revalidate } }); dynamicParams = false returns 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

  1. 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?
  2. Which pages do you prerender at build?
  3. What does the first visitor to an unprerendered product see?
  4. How do you keep prices fresh?
  5. 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 voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview