October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Next.js use cache: How to Mix Cached and Dynamic Pages with Partial Prerendering

Next.js 16 Cache Components combines prerendered shells, reusable cached work, and request-time content. Learn how to enable it and choose cache boundaries, lifetimes, and Suspense fallbacks.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Next.js 16, Cache Components is the opt-in model for combining prerendered, cached, and request-time content in one route. Enable it with cacheComponents: true, use use cache to mark work that can be reused, and place uncached work that depends on the current request behind a Suspense boundary. This lets the static shell render without forcing request-dependent content into the cache.

What Cache Components and Partial Prerendering mean

Next.js now documents this model as Cache Components, which includes Partial Prerendering. A route can combine a prerendered shell, explicitly cached results, and dynamic content that resolves for a request. As the Next.js documentation puts it, “Cache Components lets you mix static, cached, and dynamic content in a single route, giving you the speed of static sites with the flexibility of dynamic rendering.”

As an Amazon Associate I earn from qualifying purchases.

The key question is whether a piece of work can be completed during prerendering. Synchronous file reads, module imports, and pure calculations can contribute to the shell. Work that needs request-specific context cannot be known ahead of time. If that work is not cached, isolate it behind Suspense: the fallback can be part of the shell while the request-time result resolves separately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable Cache Components

Set the option in the Next.js configuration. The configuration reference lists cacheComponents as introduced in Next.js 16.0.0 and says it unifies the earlier ppr, useCache, and dynamicIO flags.

// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  cacheComponents: true,
}

export default nextConfig

After enabling it, review route behavior and data dependencies rather than assuming an existing route can be converted mechanically. The migration guide describes changes to the configuration model, including replacing route segment options with the Cache Components approach.

Choose which work to cache

Use use cache at file, function, or component scope when the result can be reused and its freshness is acceptable. Function arguments and closed-over values contribute to the cache key, so changing an input can create a separate cached result.

Cache stable, reusable work

For data that changes infrequently and does not depend on runtime request context, a cached function can make its result reusable and eligible to contribute to the prerendered output. Choose a lifetime that fits the data, and decide whether time-based expiry alone is enough or whether you need on-demand invalidation using tags and revalidation APIs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
async function getCatalog() {
  'use cache'
  // Fetch or compute reusable catalog data here.
}

The snippet illustrates the placement of the directive; it does not select a cache lifetime. The documented cacheLife profiles and custom lifetime settings are how the lifetime is specified. A configured lifetime describes cache behavior, not a promise that the origin is immediately fresh.

Keep request-specific work outside the standard cached scope

Cookies, headers, and other request context vary by request. Read the needed value outside an ordinary cached function, then pass only that value into the cached function as an explicit argument. Because arguments participate in the cache key, personalized results are partitioned by their inputs; passing a user or session value does not make that result universally shareable.

async function getGreetingFor(name: string) {
  'use cache'
  // The name is an explicit input to this cached result.
  return `Hello, ${name}`
}

// Read request-specific values outside the cached function,
// then pass only the value needed into it.

Keep the cache key as narrow as the data allows. Passing unnecessary request details can create avoidable cache variants; omitting a value that changes the result risks reusing the wrong result.

Place uncached request-time content behind Suspense

If work needs request context and should not be cached, put a boundary around the smallest useful subtree. Its fallback is eligible for the static shell; the dynamic result resolves at request time. Smaller boundaries preserve more surrounding content in the prerendered shell than wrapping an entire page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { Suspense } from 'react'

export default function Page() {
  return (
    <main>
      <h1>Catalog</h1>
      <Suspense fallback={<p>Loading account details…</p>}>
        <AccountDetails />
      </Suspense>
    </main>
  )
}

In this pattern, the surrounding page content can be part of the shell while AccountDetails resolves with request-time information. Keep the boundary around the request-dependent region, not around unrelated content that can already be prerendered.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Match the cache strategy to freshness and request dependence

  • Stable data, no request dependency: consider use cache, then choose an appropriate lifetime and invalidation method.
  • Personalized data: read the request value outside the ordinary cached scope and pass the minimum necessary value as an input, creating an explicit cache partition.
  • Request-time data that should not be cached: render it behind a Suspense boundary and provide useful fallback UI.
  • Content that must be fresh immediately: do not assume a cached result is current merely because a request was made; use a strategy whose invalidation and freshness behavior meets the requirement.

Account for cache lifetime, invalidation, and deployment

Cache behavior is a deliberate design choice, not a blanket freshness guarantee. The documented mechanisms include cache lifetime settings and tag-based on-demand revalidation. Select based on how often the underlying data changes, how much staleness is acceptable, and how quickly changes need to become visible.

The use cache: remote option is for a platform-provided dedicated cache handler. It introduces a network round trip to check the cache and typically incurs platform fees. Treat that as an operational trade-off: the actual provider support, deployment setup, and cost depend on the platform and need to be checked for the deployment in question. No universal performance gain or provider price follows from the documentation alone.

Migrate route settings deliberately

With Cache Components enabled, the migration guide describes moving away from route segment options such as dynamic, revalidate, and fetchCache toward the new caching and rendering model. Specifically, dynamic = 'force-dynamic' is no longer needed in this model, revalidate is replaced by cacheLife, and fetchCache is unnecessary inside a use cache scope.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before removing an existing setting, identify what it currently controls: request-time data, reuse duration, or fetch behavior. Then express that intent with an explicit cache boundary, lifetime, invalidation strategy, or Suspense boundary as appropriate. The migration guidance describes the model; it does not establish that every existing route can be changed without reviewing its runtime dependencies.

What the version and documentation dates establish

The configuration reference identifies cacheComponents as introduced in Next.js 16.0.0. The official documentation pages surfaced with different update dates: the Cache Components guide was dated December 20, 2025; configuration and directive references February 27, 2026; and the migration guide March 3, 2026. These dates identify the documentation versions being described, not benchmark results. The cited official material provides no relevant named benchmark or quantified speed gain.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.