{"record":{"id":"ee19f417527b3f85","repo":"vercel/next.js","slug":"cache-force-cache-used-on-fetch-for-fetchurl","errorCode":null,"errorMessage":"cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'","messagePattern":"cache: 'force-cache' used on fetch for (.+?) with 'export const fetchCache = 'only-no-store'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/patch-fetch.ts","lineNumber":707,"sourceCode":"            case 'unstable-cache':\n            case 'generate-static-params':\n              break\n            default:\n              workUnitStore satisfies never\n          }\n        }\n\n        switch (pageFetchCacheMode) {\n          case 'force-no-store': {\n            cacheReason = 'fetchCache = force-no-store'\n            break\n          }\n          case 'only-no-store': {\n            if (\n              currentFetchCacheConfig === 'force-cache' ||\n              (typeof finalRevalidate !== 'undefined' && finalRevalidate > 0)\n            ) {\n              throw new Error(\n                `cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'`\n              )\n            }\n            cacheReason = 'fetchCache = only-no-store'\n            break\n          }\n          case 'only-cache': {\n            if (currentFetchCacheConfig === 'no-store') {\n              throw new Error(\n                `cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'`\n              )\n            }\n            break\n          }\n          case 'force-cache': {\n            if (\n              typeof currentFetchRevalidate === 'undefined' ||\n              currentFetchRevalidate === 0","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/lib/patch-fetch.ts#L689-L725","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Change the conflicting fetch to { cache: 'no-store' } to match the only-no-store page policy.","Or change/remove `export const fetchCache = 'only-no-store'` if caching that fetch is intended.","Audit every fetch in the route to ensure none use force-cache or a positive revalidate."],"exampleFix":"// before\nexport const fetchCache = 'only-no-store'\nexport default async function Page() {\n  const res = await fetch('https://api/x', { cache: 'force-cache' }) // throws\n}\n\n// after\nexport const fetchCache = 'only-no-store'\nexport default async function Page() {\n  const res = await fetch('https://api/x', { cache: 'no-store' })\n}","handlingStrategy":"validation","validationCode":"// Keep page-level and per-fetch cache modes consistent\n// If fetchCache = 'only-no-store', every fetch must use cache: 'no-store'","typeGuard":"function fetchCacheAllowsCaching(mode: string): boolean {\n  return mode !== 'only-no-store'\n}","tryCatchPattern":"null","preventionTips":["When setting fetchCache at the page level, audit every fetch in the file.","Document the chosen cache mode in a comment.","Use a lint rule or code review checklist for fetch/cache consistency."],"tags":["fetch","fetch-cache","config-conflict"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}