Next.js Discord

Discord Forum

Bug - NextJS caching does not work on first load

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
I've tried unstable_cache, react cache, fetch, etc... I cant get it to work

I'm doing a simple db fetch based on a subdomain param

im doing the call 4 times on page load. - I expect it to actually prisma query once and use cache for the remaining 3. instead it does all 4 queries. This negatively impacts my loading time significantly

on refresh - it uses the cache (no queries)

Is this a known bug? If I make my own in memory cache I can get around this but man this sucks.

1 Reply

Saltwater CrocodileOP
adding a count variable in that function call (currently i have it wrapped in unstable_cache)
1,2,3,4 on first load

nothing on refresh
5,6,7,8 on Cmd-shift-r (reload without cache in chrome)