Next.js Discord

Discord Forum

Issues with page data caching on Next 14

Answered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
Hey all, I'm having some issues with caching. To my understanding, the following page should be cached and revalidate every hour (example taken from https://youtu.be/XBbXciVXWlQ?si=T5GIwVD0LzrwBsD9):

export default function Test() {
    function randomNumber() {
        return Math.floor(Math.random() * 1000);
    }
    return <div>
        {randomNumber()}
    </div>
}


This does not appear to be happening in the repo, and I get a new random number every time I refresh the page. Is there anything that might be the cause?
Answered by Palomino
Try running on production mode
View full answer

3 Replies

Are you on dev mode?
Palomino
Try running on production mode
Answer
American ChinchillaOP
that worked! thanks