Next.js Discord

Discord Forum

fetch memoization in Next 15

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Does Next 15 actually still have fetch memoization and deduping?

Between Next 14 and Next 15 I'm suddenly seeing a bunch of duplicate fetch requests that weren't duplicated before:

all these requests are identical but it doesn't seem to be deduping them for some reason

11 Replies

@Sun bear Does Next 15 actually still have fetch memoization and deduping? Between Next 14 and Next 15 I'm suddenly seeing a bunch of duplicate fetch requests that weren't duplicated before: all these requests are identical but it doesn't seem to be deduping them for some reason
to dedupe and cache the request you need to add force-cache to them. In previous versions of Next.js, using fetch would have a default cache value of force-cache. This changed in version 15, to a default of cache: no-store
Sun bearOP
according to the docs the memoization per request is independent of the data cache, so the cache setting shouldn’t affect it.
it applies to all “GET” requests
and also, I was using no-store in next 14 and deduping worked properly
@Sun bear https://nextjs.org/docs/app/building-your-application/caching#request-memoization
the docs are outdated. Nextjs team removed all the default caching behaviour. Caching is now opt-in instead of opt-out
Sun bearOP
as far as I can tell they only changed the behaviour of the data cache, not request memoization
@@ts-ignore https://nextjs.org/blog/next-15#caching-semantics
Eulophid wasp
as stated by OP, request memoization is independent of the data cache. It is based on a single render pass. Even if your data is uncached and your component tree triggers more than one of the same fetch call. It is supposed to be memoized within the memoization layer
"Whether the data is cached or uncached, the requests are always memoized to avoid making duplicate requests for the same data during a React render pass."
https://nextjs.org/docs/app/building-your-application/caching#data-cache