Understanding Cache in next.js
Answered
Ping me for help posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/755810867878297610/5ab9ece60bc14c554a7376a599d3deb3.webp?size=256)
Ping me for helpOP
I had a question. so fetch requests are cached by default, right?
Answered by Russian Blue
So if im not mistaken, after 5 mins has passed and you requested the same url, you are able to request new data, however if you request before 5 mins pass, you can only access cached data
6 Replies
![Avatar](https://cdn.discordapp.com/avatars/755810867878297610/5ab9ece60bc14c554a7376a599d3deb3.webp?size=256)
Ping me for helpOP
and if I add next: revalidate: 300, then it'll revalidate every 5 mins, right?
for mongodb data api
const response = await fetch(this.url + action, {
...options,
next: {
revalidate: 300,
...this.next,
},
so this code will revalidate every 5 min, right?
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Russian Blue
So if im not mistaken, after 5 mins has passed and you requested the same url, you are able to request new data, however if you request before 5 mins pass, you can only access cached data
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Russian Blue
It wont automatically fetch new data because that may cause redundant requests
![Avatar](https://cdn.discordapp.com/avatars/890486507872342027/cba9267c0173c6acfde7fa4ba0e70f94.webp?size=256)
Arinji
^^ Correct
You will only see the new data until you make a request to it again.
You will only see the new data until you make a request to it again.