Next.js Discord

Discord Forum

Output of server component not cached

Answered
Schneider’s Smooth-fronted Caima… posted this in #help-forum
Open in Discord
Original message was deleted.
Answered by Rafael Almeida
but yeah in your case it is npm run build && npm run start then it should work
View full answer

9 Replies

afaik the dev server doesn't cache anything so you can work with fresh data from the API. if you want to test the cache you need to run the prod build (next build and next start)
no, start is a different command that runs the prod server
also, you only need next build if you are running the prod server since next dev doesn't use it. so no point running it before starting the dev server
you need to build the project before running the prod server
next is the CLI name, it is usually ran from your package.json file so you can't run it directly. you run it through npm: npm run x, it depends on how you configured the project
I don't say npm run task because people use different package managers so it is not always correct
but yeah in your case it is npm run build && npm run start then it should work
Answer
yeah I am not sure the docs mentions that the cache doesn't work with dev at all, this would be nice to include in the cache page
you can mark the messages yourself by right clicking it then Apps > Mark Solution