use cache and unstable_cache both have inconsistent behavior between refresh and client-side nav
Unanswered
German Shorthaired Pointer posted this in #help-forum
German Shorthaired PointerOP
Using cacheComponents: true with 'use cache' + cacheLife('max') + cacheTag.
Behavior (npm run build + npm start):
Hard refresh → prerendered static HTML, cache hit ✅
First <Link> navigation to same page → cache miss, fresh data fetched ❌
Subsequent <Link> navigations → served from cache ✅
The problem:
If I change a product's title after build, a hard refresh correctly serves the old cached title. But the first <Link> navigation fetches fresh data and shows the updated title — meaning it's still hitting the API/DB even though I never called revalidate. So it's not truly static — the cache isn't being used at all on first client navigation, only on subsequent ones. This causes a mismatch where hard refresh and client navigation show different content until the cache warms up.
With unstable_cache it's the opposite problem:
After revalidating and hard refreshing the product page I correctly see the new title, but if I client-side navigate to the product page from another page (without a hard refresh on the product page first) I see the stale title.
So both APIs have an inconsistency, just in opposite directions. Is this a known limitation of 'use cache' or am I missing something in my setup? What's the recommended approach to get consistent behavior between hard refresh and client-side navigation?
Behavior (npm run build + npm start):
Hard refresh → prerendered static HTML, cache hit ✅
First <Link> navigation to same page → cache miss, fresh data fetched ❌
Subsequent <Link> navigations → served from cache ✅
The problem:
If I change a product's title after build, a hard refresh correctly serves the old cached title. But the first <Link> navigation fetches fresh data and shows the updated title — meaning it's still hitting the API/DB even though I never called revalidate. So it's not truly static — the cache isn't being used at all on first client navigation, only on subsequent ones. This causes a mismatch where hard refresh and client navigation show different content until the cache warms up.
With unstable_cache it's the opposite problem:
After revalidating and hard refreshing the product page I correctly see the new title, but if I client-side navigate to the product page from another page (without a hard refresh on the product page first) I see the stale title.
So both APIs have an inconsistency, just in opposite directions. Is this a known limitation of 'use cache' or am I missing something in my setup? What's the recommended approach to get consistent behavior between hard refresh and client-side navigation?
2 Replies
@B33fb0n3 unstable_cache is pretty unstable sometimes and will be removed in the next major version. Use cacheComponents rather than unstable cache
Palomino
probably why its called unstable_cache
🤣
🤣