Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Next.js 16+ · Const

fetchCache

fetchCache is a route-segment export that overrides the default caching behavior of fetch requests in a layout or page. Its policy controls whether requests are cached, uncached, or required to follow one of those modes.

How it works

Declare fetchCache in a layout or page to set the default caching behavior for every fetch request in that route segment. Individual fetch calls can still provide their own cache option, while stricter modes can force or require caching or prevent it.

Syntax

export const fetchCache = 'auto' | 'default-cache' | 'only-cache' | 'force-cache' | 'force-no-store' | 'default-no-store' | 'only-no-store'

Key points

  • It is exported from a layout or page and applies a default fetch cache policy across that route segment.
  • auto is the default and follows the position of Dynamic API usage when deciding whether requests are cached.
  • only-cache requires caching and causes an error when a fetch explicitly uses no-store.
  • force-cache overrides individual fetch cache settings so every request uses force-cache.
  • force-no-store makes every fetch request use no-store, producing uncached behavior.

Common mistakes

  • Use fetchCache only when the route needs a deliberate override of normal fetch caching behavior.

Example: Cached route-segment fetch

export const fetchCache = 'default-cache'

export default async function Page() {
  const res = await fetch('https://api.example.com/products')
  const products = await res.json()
  return <pre>{JSON.stringify(products, null, 2)}</pre>
}

This page makes uncategorized fetch requests cache by default within the route segment.

When to use it

Set a cached default

A route should cache fetches that do not declare a policy.

Enforce caching

A route must reject uncached fetch calls.

Force dynamic data

A route must prevent all fetch caching.

Interview questions

QWhat does fetchCache configure?

fetchCache is a route-segment configuration that overrides the default cache option for fetch requests in a layout or page. Its value is one of the documented cache policies, such as auto, default-cache, or force-no-store.

Follow-up: How would you make every fetch cached unless a request explicitly opts out? Use only-cache, which changes an unspecified request to force-cache but errors when a request uses no-store.

QWhat does the auto value do?

auto preserves the normal behavior: fetches before Dynamic APIs use their supplied cache option, while fetches after Dynamic APIs are not cached. It is the default setting.

Follow-up: What happens if a request must be cached even after a Dynamic API? Use force-cache, which sets every fetch request's cache option to force-cache.

QHow do default-cache and only-cache differ?

default-cache changes requests without an explicit cache option to force-cache, while requests that specify a cache option retain that choice. only-cache is stricter because it also rejects fetch calls using no-store.

Follow-up: When would default-no-store be preferable? Use it when unspecified requests should be uncached while explicitly configured cache behavior remains available.

  • cache
  • force-cache
  • no-store
  • Dynamic APIs
  • Route Segment Config

Source: Route Segment Config - File Conventions - Next.js. Checked 2026-10-15.