Issue with use cache + Cache Components: build cache not respected on first client-side navigation
Unanswered
German Shorthaired Pointer posted this in #help-forum
German Shorthaired PointerOP
Using cacheComponents: true with 'use cache' + cacheLife('max') + cacheTag.
Behavior:
Hard refresh → serves prerendered static HTML, 'use cache' function never called ✅
First <Link> navigation to same page → cache miss, function called, fresh data fetched ❌
Subsequent <Link> navigations → served from cache ✅
Looks like client-side navigation starts from an empty cache rather than reusing the build-time cache? Running npm run build + npm start locally.
Worth noting: switching back to unstable_cache fixes this completely — first <Link> navigation also serves from build cache with no fresh fetch. That's the behavior I want. But since unstable_cache is now considered legacy in favor of 'use cache', I'd prefer to use the new API — however it seems like a regression compared to unstable_cache in this regard. Is this a known limitation of 'use cache' or am I missing something in my setup?
Behavior:
Hard refresh → serves prerendered static HTML, 'use cache' function never called ✅
First <Link> navigation to same page → cache miss, function called, fresh data fetched ❌
Subsequent <Link> navigations → served from cache ✅
Looks like client-side navigation starts from an empty cache rather than reusing the build-time cache? Running npm run build + npm start locally.
Worth noting: switching back to unstable_cache fixes this completely — first <Link> navigation also serves from build cache with no fresh fetch. That's the behavior I want. But since unstable_cache is now considered legacy in favor of 'use cache', I'd prefer to use the new API — however it seems like a regression compared to unstable_cache in this regard. Is this a known limitation of 'use cache' or am I missing something in my setup?