serverComponentsHmrCache
The experimentalserverComponentsHmrCache option allows you to cachefetch responses in Server Components across Hot Module Replacement (HMR) refreshes in local development. This results in faster responses and reduced costs for billed API calls.
By default, the HMR cache applies to allfetch requests, including those with thecache: 'no-store' option. This means uncached requests will not show fresh data between HMR refreshes. However, the cache will be cleared on navigation or full-page reloads.
You can disable the HMR cache by settingserverComponentsHmrCache tofalse in yournext.config.js file:
importtype { NextConfig }from'next'constnextConfig:NextConfig= { experimental: { serverComponentsHmrCache:false,// defaults to true },}exportdefault nextConfigGood to know: For better observability, we recommend using the
logging.fetchesoption which logs fetch cache hits and misses in the console during development.
Was this helpful?