Does a hard refresh invalidate data cache by "unstable_cache"?
Answered
Short mackerel posted this in #help-forum
Short mackerelOP
Just want to verify and understand a bit more about unstable_cache.
Been experimenting on my own function in the server (used by server component). From the screenshot, it seems like if I use "unstable_cache" it caches the value between normal refresh, but gets invalidate when doing a hard refresh.
Without "unstable_cache", the function doesn't do any cache between any kind of refresh.
I'm assuming that a hard-refresh invalidate a data-cache? Does this mean if someone do a hard-refresh, every client connected to the server will get fresh data as well?
Been experimenting on my own function in the server (used by server component). From the screenshot, it seems like if I use "unstable_cache" it caches the value between normal refresh, but gets invalidate when doing a hard refresh.
Without "unstable_cache", the function doesn't do any cache between any kind of refresh.
I'm assuming that a hard-refresh invalidate a data-cache? Does this mean if someone do a hard-refresh, every client connected to the server will get fresh data as well?
Answered by joulev
no, unstable_cache is entirely on the server, it doesn't know (or care) whether the user does a hard refresh or a soft refresh
3 Replies
@Short mackerel Just want to verify and understand a bit more about unstable_cache.
Been experimenting on my own function in the server (used by server component). From the screenshot, it seems like if I use "unstable_cache" it caches the value between *normal refresh,* but gets invalidate when doing a *hard refresh*.
Without "unstable_cache", the function doesn't do any cache between any kind of refresh.
I'm assuming that a hard-refresh invalidate a data-cache? Does this mean if someone do a hard-refresh, every client connected to the server will get fresh data as well?
no, unstable_cache is entirely on the server, it doesn't know (or care) whether the user does a hard refresh or a soft refresh
Answer
i just verified it in one of my prod apps. i updated the upstream data and does a force refresh on the client. the data returned is still the old stale data not the new updated data because i only refreshed the page, i never told nextjs to revalidate the cache
Short mackerelOP
Thank you @joulev ! that makes more sense