Is the preload() void pattern with cache() working for anyone else on App Router?
Unanswered
Belgian Hare posted this in #help-forum
Belgian HareOP
Title is pretty self-explanatory, for me it looks like it does nothing to preload the cached function.
https://nextjs.org/docs/app/building-your-application/data-fetching/caching#preload-pattern-with-cache
https://nextjs.org/docs/app/building-your-application/data-fetching/caching#preload-pattern-with-cache
7 Replies
@Belgian Hare Are you also using that preload function from a page? Check out the next code example in the link you sent, it doesn't get called automatically
Belgian HareOP
Yeah, I'm calling it in a page
In you dev environment do you see it being called? Like in my logs I see something like this when a fetch call is made:
Belgian HareOP
These are for http fetch requests, right? I'm using Prisma so is not logging anything. It does get called however, it just doesn't cache it and show the Loading Spinner + make another call.
Oh ok, I haven't used that yet except for fetch functions. I thought the cache function worked the same as fetch in terms of caching, but maybe its not identical and this hasn't been setup yet?
Well, looking at the docs again, the docs are using the
cache function and fetch, so that's confusing.Belgian HareOP
Totally! Would be lovely to have some feedback if those custom cache() calls are being really cached or not just like you have with the regular patched fetch()