Difference between React.cache and unstable_cache from 'next/cache'
Answered
Barbary Lion posted this in #help-forum
Barbary LionOP
Help me understand the difference between these two. And why'd one want to use them together ?
https://github.com/ethanniser/NextMaster/blob/main/src/lib/unstable-cache.ts
https://github.com/ethanniser/NextMaster/blob/main/src/lib/unstable-cache.ts
Answered by B33fb0n3
the react cache is not really a cache. It's more a place where you can put data, that will be memorized for one request (clientside).
The unstable_cache (named data cache) is a serverside cache that saves values. It will be the same for other reuqests as well
The unstable_cache (named data cache) is a serverside cache that saves values. It will be the same for other reuqests as well
5 Replies
the react cache is not really a cache. It's more a place where you can put data, that will be memorized for one request (clientside).
The unstable_cache (named data cache) is a serverside cache that saves values. It will be the same for other reuqests as well
The unstable_cache (named data cache) is a serverside cache that saves values. It will be the same for other reuqests as well
Answer
Barbary LionOP
so, basically React.cache is for deduping multiple requests, r?
and unstable_cache is like "storage" for requests data on server side
yea
Barbary LionOP
got it thanks for the clarification