Does `{ next: { revalidate: 300 } }` revalidate every 300 seconds?
Answered
Cape lion posted this in #help-forum
Cape lionOP
Even if nobody visits my site for 5 hours (as an example)?
Answered by aardani
Revalidate:300 means that if a person visits an outdated page that has taken over 300 seconds then Next.js will trigger a background revalidation. Which mean that the next time user visit it will be refreshed.
11 Replies
No revalidate : 300 does not mean revalidate every 300 seconds
Revalidate:300 means that if a person visits an outdated page that has taken over 300 seconds then Next.js will trigger a background revalidation. Which mean that the next time user visit it will be refreshed.
Answer
Case A:
If a user request the page at 299th second it will show cached page.
If a user request the page at 301th second it will still show cached page but trigger page revalidation in the background
If a user request the page at 302th second then it will show the new page
Case B:
If a user request the page at 299th second it will show cached page.
No one has accessed the page between the 300th second and 4999th second.
If a user request the page at 5000th second it will still show cached page but trigger page revalidation in the background
No one has accessed the page between the 5001st second and 5999th second.
If a user request the page at 6000th second then it will show the new page
If a user request the page at 299th second it will show cached page.
If a user request the page at 301th second it will still show cached page but trigger page revalidation in the background
If a user request the page at 302th second then it will show the new page
Case B:
If a user request the page at 299th second it will show cached page.
No one has accessed the page between the 300th second and 4999th second.
If a user request the page at 5000th second it will still show cached page but trigger page revalidation in the background
No one has accessed the page between the 5001st second and 5999th second.
If a user request the page at 6000th second then it will show the new page
That is as far as how I understand it based on the Documentation alone.
Cape lionOP
Meaning that it's not really suitable if someone wants the new data after refreshing, since they would have to fresh twice to see the new data
@Cape lion Meaning that it's not really suitable if someone wants the new data after refreshing, since they would have to fresh twice to see the new data
If you have many user its no longer a problem
which is the point of that design i think
User A could be seeing old data at 300th second
but
User B is seeing new data at 300.5th second
but
User B is seeing new data at 300.5th second
@Cape lion Meaning that it's not really suitable if someone wants the new data after refreshing, since they would have to fresh twice to see the new data
Revalidate is for data where seeing slightly stale data is acceptable, e.g. daily updates of some metric on the homepage
It’s not suitable if you want fresh data all the time
In that case use dynamic rendering