Free tools Windows power users keep installed

One-click scans. No signup required.

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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Next.js caching depends on which version and caching model your app uses. Next.js 15 documents four separate cache layers; the current Cache Components model, introduced in Next.js 16, makes caching more explicit: enable it, mark code with use cache, and set its lifetime with cacheLife. For updates that should take effect before a timer expires, use tag- or path-based invalidation.

Which Next.js caching model applies to your app?

Start with the version and configuration in your project, not with a general rule that Next.js “caches” or “doesn’t cache” everything. The Next.js 15 guide describes the earlier App Router model. Current documentation presents Cache Components as a Next.js 16 feature enabled through cacheComponents: true. The newer model changes how caching is expressed, so do not apply its defaults to a Next.js 15 app or carry older route-segment settings into a migration without checking the target version.

Model How caching is expressed What to keep in mind
Next.js 15 documented model Separate mechanisms include request memoization, the Data Cache, the Full Route Cache, and the client Router Cache. The guide describes caching in terms of fetch behavior and static rendering. Check the version-specific guide for the behavior relevant to your route and fetch options.
Next.js 16 Cache Components Opt in with cacheComponents: true; mark a function, component, or file boundary with use cache; set a lifetime with cacheLife. Pages are dynamic by default under this model unless code is explicitly cached. Runtime data access that is not handled appropriately can produce development or build errors.

For the older model, see the Next.js 15 caching guide. For the current model and migration details, consult the Cache Components migration guide alongside the reference for your installed Next.js version.

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

What are the four cache layers in the Next.js 15 model?

The four mechanisms do different jobs and live in different places. Treating them as one cache makes it harder to predict what is reused or how to refresh it.

Layer Where it applies What it reuses
Request memoization Server, within a request Repeated eligible data work during the same request; it is not a persistent cache shared across requests.
Data Cache Server, persistent and revalidatable Data from eligible cached fetches, subject to the configured revalidation behavior.
Full Route Cache Server Rendered route output, including HTML and the React Server Component (RSC) payload.
Router Cache Client RSC payload used by client-side navigation.

These distinctions are documented in the Next.js 15 caching guide. The guide also describes static rendering and cached fetches; which behavior you get depends on the route and the options used, so inspect those instead of assuming a single default for the entire application.

How do you opt into Cache Components and cache code?

In the current model, caching is an explicit boundary. A minimal setup enables the feature in next.config.ts, then marks the function or component to cache and selects one lifetime profile for that invocation.

// next.config.ts
const nextConfig = {
  cacheComponents: true,
}

export default nextConfig
import { cacheLife } from 'next/cache'

async function getPublicCatalog() {
  'use cache'
  cacheLife('hours')

  return loadCatalog()
}

cacheLife can use a built-in profile, a custom profile configured in next.config.ts, or an inline object. Only one cacheLife call should execute in a given invocation. Choose the profile based on how long the result can be reused and how quickly it must reflect updates; do not treat the example profile as a universal recommendation. See the Cache Components configuration reference, use cache reference, and cacheLife reference for version-specific details.

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

What cacheLife controls

cacheLife controls the cached result’s time-based staleness, revalidation, and expiration behavior. These are separate from event-driven invalidation: a timer determines when an entry’s age matters, while a tag or path lets the application respond to a known change.

The current use cache reference documents defaults of five minutes for client-side stale behavior, fifteen minutes before server-side revalidation, and no time-based expiration. These are defaults stated in the current documentation, not timeless guarantees; check the reference for the Next.js version you deploy. The stale value governs client Router Cache behavior and is not a direct setting of the HTTP Cache-Control: max-age header. The reference also documents a 30-second minimum for client-side stale timing to keep prefetched links usable.

How should you choose between a lifetime, a tag, and a path?

Use time when data can safely remain unchanged for a chosen interval. Use invalidation when a known event—such as a content update or successful mutation—should affect cached output before that interval is up. These controls can be combined: a longer lifetime can limit routine refreshes while an update event invalidates the relevant entries.

Control Use it when Scope
cacheLife A defined freshness window is acceptable and time should govern revalidation or expiration. The cached function, component, or output covered by the cache boundary.
cacheTag with revalidateTag A known data change should refresh related cached entries, even if they appear in multiple places. Entries associated with the tag.
revalidatePath A change should invalidate output for a particular route path. The specified path.

For example, a cached function that loads published articles can attach a shared tag:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { cacheLife, cacheTag } from 'next/cache'

async function getArticles() {
  'use cache'
  cacheLife('days')
  cacheTag('articles')

  return loadArticles()
}

When an article changes, current documentation describes revalidateTag('articles', 'max') as marking matching entries stale for stale-while-revalidate behavior: a request can use stale content while the framework refreshes it. This differs from the deprecated one-argument form, which expires entries immediately so that the next request has to perform a blocking revalidation or cache miss. Choose the behavior that fits the update flow rather than copying an older one-argument example. See the revalidateTag reference and revalidation guide. The same guide documents updateTag as another tag-based option and revalidatePath for path-based invalidation.

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

How does time-based revalidation differ in the older model?

In the Next.js 15 model, a cached fetch can set next.revalidate in seconds. After the interval, a request may receive the stale value while Next.js refreshes the cached data in the background. If that refresh fails, the prior cached value is retained. This is time-based data revalidation in the older model; it is not interchangeable with Cache Components’ cacheLife settings.

const response = await fetch(dataUrl, {
  next: { revalidate: 3600 },
})

The number in this example is a configuration value in seconds, not a recommended interval for every resource. Review the Next.js 15 guide for the behavior and options supported by the version your project uses.

What changes when migrating to Cache Components?

Migration is a change in the caching model, not just a rename of one setting. The migration guide says route-segment options such as dynamic, revalidate, and fetchCache are replaced by explicit use cache boundaries and cacheLife in the Cache Components model.

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.
  • Audit route-segment settings and decide which outputs should have explicit cache boundaries.
  • Identify runtime data that must remain uncached or request-specific, and handle it as the target version’s guide requires.
  • Test development and production builds: unhandled uncached or runtime data access can raise errors during development or build.
  • Verify invalidation behavior after mutations, including whether stale-while-revalidate is acceptable or the next read must wait for fresh data.

Follow the migration guide for the exact behavior of the target release; do not assume Next.js 15 defaults or examples carry over unchanged.

Which runtime and deployment constraints should you check?

Cache Components require the Node.js runtime and do not work with the Edge Runtime according to the current guide. Adapter and deployment support may also vary by platform, including how cache persistence works. Before enabling this model in production, confirm that the runtime selected for each route is compatible and consult the deployment platform’s documentation for its adapter and cache behavior. The current guide to Cache Components and partial prerendering covers the documented runtime constraint.

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.