vercel/next.js · error · Error

cache: 'force-cache' used on fetch for ${fetchUrl} with 'exp

Error message

cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'

What it means

Thrown by patch-fetch when a fetch() inside a route uses cache:'force-cache' (or a positive revalidate) while the route module declares `export const fetchCache = 'only-no-store'`. The only-no-store mode forbids any caching fetch, making the combination contradictory and a likely developer mistake.

Source

Thrown at packages/next/src/server/lib/patch-fetch.ts:707

            case 'unstable-cache':
            case 'generate-static-params':
              break
            default:
              workUnitStore satisfies never
          }
        }

        switch (pageFetchCacheMode) {
          case 'force-no-store': {
            cacheReason = 'fetchCache = force-no-store'
            break
          }
          case 'only-no-store': {
            if (
              currentFetchCacheConfig === 'force-cache' ||
              (typeof finalRevalidate !== 'undefined' && finalRevalidate > 0)
            ) {
              throw new Error(
                `cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'`
              )
            }
            cacheReason = 'fetchCache = only-no-store'
            break
          }
          case 'only-cache': {
            if (currentFetchCacheConfig === 'no-store') {
              throw new Error(
                `cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'`
              )
            }
            break
          }
          case 'force-cache': {
            if (
              typeof currentFetchRevalidate === 'undefined' ||
              currentFetchRevalidate === 0

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Change the conflicting fetch to { cache: 'no-store' } to match the only-no-store page policy.
  2. Or change/remove `export const fetchCache = 'only-no-store'` if caching that fetch is intended.
  3. Audit every fetch in the route to ensure none use force-cache or a positive revalidate.

Example fix

// before
export const fetchCache = 'only-no-store'
export default async function Page() {
  const res = await fetch('https://api/x', { cache: 'force-cache' }) // throws
}

// after
export const fetchCache = 'only-no-store'
export default async function Page() {
  const res = await fetch('https://api/x', { cache: 'no-store' })
}
Defensive patterns

Strategy: validation

Validate before calling

// Keep page-level and per-fetch cache modes consistent
// If fetchCache = 'only-no-store', every fetch must use cache: 'no-store'

Type guard

function fetchCacheAllowsCaching(mode: string): boolean {
  return mode !== 'only-no-store'
}

Try / catch

null

Prevention

When it happens

Trigger: A route file has `export const fetchCache = 'only-no-store'` and inside it calls fetch(url, { cache: 'force-cache' }) or fetch(url, { revalidate: 60 }). patch-fetch detects the conflict and throws.

Common situations: Adding fetchCache='only-no-store' to force dynamic data but forgetting to update existing fetch calls that still opt into caching. Copying a fetch from another route without reconciling the page-level cache mode.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/ee19f417527b3f85. Report an issue: GitHub.