Next.js Discord

Discord Forum

Is math.random() affecting performance?

Unanswered
Morelet’s Crocodile posted this in #help-forum
Open in Discord
Morelet’s CrocodileOP
I have a decorative element on my page that utilizes math.random in a server component to choose values out of an array. Since adding this, I have noticed that server response time is slower and that the random result is different on every page load instead of hitting a cache.

Is it possible to cache these random values when they're loaded for the first time, or is my slower server response time potentially coming from somewhere else?

0 Replies