Next.js Discord

Discord Forum

Explanation of cache profiles behavior

Unanswered
effeKtSVK posted this in #help-forum
Open in Discord
Hello everyone, I have a question about the cache profiles that are available for the new 'use cache' directive.

I'm interested what would happen in a certain scenario, let's say my cache profile is:
stale: 1 minute
revalidate: 5 minutes
expire: 10 minutes
(this is basically same as the 'hours' (and longer), just uses shorter values to make it easier to understand)

What would happen to following requests, assuming the first request already went through (which created the cache)?
- request 2 at minute 3 (after stale but before revalidate)
- request 3 at minute 4 (still after stale but before revalidate)
- request 4 at minute 7 (after revalidate)

It doesn't make sense to me, which logic is applied, whether the data is still considered "stale" and no fetch is done, or if the revalidation will happen. If any of those are the case, then isn't one of the values (stale or revalidate) useless?
In case the data is considered stale, that would be the same as "stale: 5 min, revalidate: 5 min".
In case the data is revalidated, that would be the same as "stale: 1 min, revalidate: 1 min".

0 Replies