Next.js Discord

Discord Forum

Does caching during `npm run dev` just not work?

Answered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
Hello,

As suggested by the nextjs docs, I am re-using the same fetch calls in multiple server components and leveraging the caching to have data on demand.

This works perfectly when I build the project and run it with next start, but on dev it seems to be sending the API call every time the fetch is being called and no caching is taking place.

Is that just normal? Cause this sound really weird.
Answered by B33fb0n3
I couldn't find a way. I just looked a bit around on how to opt in to cache during developement and found this issue: https://github.com/vercel/next.js/discussions/48481

Maybe this is a possible archivable solution for you:
https://github.com/vercel/next.js/discussions/48481#discussioncomment-7662771

Else I don't know any way
View full answer

5 Replies

@B33fb0n3 yes, that's normal. Caching in dev is mostly disabled. If you build your app and start your app in production, it will cache normal
Satin AngoraOP
Is there no way around that? kinda seems weird that I have to build the app every time if I want to test how it actually will behave
@Satin Angora Is there no way around that? kinda seems weird that I have to build the app every time if I want to test how it actually will behave
I couldn't find a way. I just looked a bit around on how to opt in to cache during developement and found this issue: https://github.com/vercel/next.js/discussions/48481

Maybe this is a possible archivable solution for you:
https://github.com/vercel/next.js/discussions/48481#discussioncomment-7662771

Else I don't know any way
Answer
@Satin Angorasolved?