#next.js 15 fetch cache
1 messages · Page 1 of 1 (latest)
Hi @molten carbon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
In Next.js 15, fetch requests are no longer cached by default [Upgrading to version 15]. The behavior of cache: 'no-store' depends on whether it is executed on the server or the client:
Server-Side Execution (Server Components & Route Handlers)
On the server, cache: 'no-store' interacts with the Next.js Data Cache. It ensures that the resource is fetched from the remote server on every request, bypassing the persistent Data Cache [Fetch API Reference].
However, there is a nuance regarding Request Memoization:
- Server Components: Even with
no-store, Next.js (via React) will still memoizeGETrequests within the same render pass. If you call the samefetchwithno-storetwice in the same React component tree, the second call will return the memoized result from the first call to avoid duplicate network requests during a single render [Request Memoization; Github Issue 73589]. - Route Handlers: Request memoization does not apply to Route Handlers because they are not part of the React component tree [Request Memoization].
Client-Side Execution
In the browser, the cache option in fetch follows the standard Web API behavior and indicates how the request interacts with the browser's HTTP cache, rather than the Next.js Data Cache [Data Cache; Fetch API Reference].
Key Differences in Next.js 15
- Default Behavior: Unlike previous versions,
fetchrequests in Next.js 15 are not automatically cached. You must explicitly usecache: 'force-cache'to opt into the Data Cache [Upgrading to version 15]. - Development (HMR): In local development, Next.js may still cache
no-storeresponses across Hot Module Replacement (HMR) refreshes to improve performance, unless you disableserverComponentsHmrCachein your config [Server Components HMR Cache; Fetch Troubleshooting].