Replies: 1 comment
-
Thanks for bringing this up — I also noticed this difference and have been wondering about it. According to the official documentation, the illustration suggests that:
In other words, request memoization should happen before any data cache is involved, which would avoid repeated cache lookups during a single render pass. However, the actual implementation appears to apply them in the reverse order:
If I’m understanding this correctly, this means that the data cache (e.g., file system or Redis) may be accessed multiple times for the same request within one server render, even though memoization could have short-circuited that. This might not cause functional issues, but it does seem to differ from the mental model the docs imply — and it could have performance implications in cache-heavy environments. Is this ordering intentional? I'd really appreciate any clarification or context from the team. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When you check the official documentation of NextJS, you can find the following illustration.
According to the illustration, Request Memoization is applied before DataCache, meaning that if memoization occurs, cacheHandler is not accessed.
However, the actual implementation is structured as follows:
patchFetch(dedupeFetch(fetch))
This means that DataCache is checked and accessed before Request Memoization, which differs from what is explained in the official documentation.
Is this behavior intentional?
I think it should be applied as follows to work as the illustration shows.
dedupeFetch(patchFetch(fetch))
Beta Was this translation helpful? Give feedback.
All reactions