Next.js Discord

Discord Forum

Server action being cached in production but not dev mode

Unanswered
Russian Blue posted this in #help-forum
Open in Discord
Avatar
Russian BlueOP
I have a server action which returns random numbers and I have a server component that displays the value returned. If I run the app in development and refresh the page the returned number is dynamic but if I build and run in production environment and refresh the number remains the same. I assume this is because the page is being cached.

My question is, how do I prevent the caching and allow the action to return a new generated number every time it's called?

2 Replies

Avatar
Russian BlueOP
Okay so what I've now learned is that it has nothing to do with the server action. The page is actually static. I can make it dynamic by adding parameters to the route. But what if I don't need parameters but still want the route to be dynamic?
Avatar
Russian BlueOP
Why is it that nextjs dynamically renders if a page uses fetch, or parameters but still renders it as static if you use a server action?