-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Looking at the config options, there are several conditions/checks to cancel or initiate a request. What is the order of evaluation for each of these checks? The list I am aware of:
- ➕
refreshInterval: generate requests everynms - ➕
revalidateOnFocusgenerate requests on focus event - ➕
mutate(undefined, {forceRevalidate: true})generates single request - ➖
dedupingIntervalfilters requests withinnms time span - ➖
revalidateDebouncedelays requests fornms
Especially for the mutate function, it seems like the dedupingInterval is still honoured. On the one hand, I understand this, as you would still want to deduplicate e.g. 2 mutates in a short time (e.g. 2 seconds). On the other hand, for the focus event, you would not want to revalidate all caches for every 2 seconds of being away from a page.
In other words, ideally, there would be two timers, one for deduping (relatively short time e.g. 2 seconds), another one for marking the data in cache as stale (e.g. after 1 minute), but without removing it (ttl removes the data from cache completely, leaving one with an empty cache).
Potential solutions:
ttlshould not remove the data from the cache, but only mark it as stale. This way the app remains usable if there is no network connection, even afterttlexpired.revalidateOnFocusshould be a time span: "auto revalidate when window gets focused after interval in milliseconds.refreshWithoutFocus = trueoption should be added. Setting it to false will not send requests when there is no focus and OnFocus will cause the refresh to occur immediately.
What would you think is the best solution? Am I missing some details or other solutions? Looking forward to hear your take on this!