Is request memoization enabled by default?
Unanswered
Pacific sandlance posted this in #help-forum
Pacific sandlanceOP
From the docs:
This sounds like it's enabled by default, as opposed to the Data Cache which you explicitly need to add:
to each request.
Am I understanding this correctly?
Next.js extends the fetch API to automatically memoize requests that have the same URL and options. This means you can call a fetch function for the same data in multiple places in a React component tree while only executing it once.
This sounds like it's enabled by default, as opposed to the Data Cache which you explicitly need to add:
fetch(`https://...`, { cache: 'force-cache' })
to each request.
Am I understanding this correctly?
2 Replies
It’s just de-duping your requests that happen in the same render pass, imagine you call it in layout, then again in metadata and then again in page, you’ll only call it once
Pacific sandlanceOP
I know what it does, was confirming that it's enabled automatically without needing
cache: 'force-cache'