Determining age of cached fetch response?
Unanswered
Schneider’s Smooth-fronted Caima… posted this in #help-forum
Schneider’s Smooth-fronted CaimanOP
I'm using fetch caching for API calls to a paid web service. I want to show a timestamp of the last fetch on the page to the user so they know how stale the data is.
I can't find any way to find the age of the cached response (or even if the response was a cache MISS or HIT).
Is there some way to do this I'm missing?
I can't find any way to find the age of the cached response (or even if the response was a cache MISS or HIT).
Is there some way to do this I'm missing?
2 Replies
Schneider’s Smooth-fronted CaimanOP
Looks like the real solution is to
'use cache'
to cache the function, not the fetch, but I can't use Canary at the moment 😦Sloth bear
I guess you could wrap your fetch call (with cache: no-store) with unstable_cache? Then add whatever extra data you need, e.g.
Date()