Next.js Discord

Discord Forum

Difference between React.cache and unstable_cache from 'next/cache'

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Avatar
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
Image
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
View full answer

5 Replies

Avatar
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
Answer
Avatar
Barbary LionOP
so, basically React.cache is for deduping multiple requests, r?
and unstable_cache is like "storage" for requests data on server side
Avatar
yea
Avatar
Barbary LionOP
got it thanks for the clarification