You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 every nms
➕ revalidateOnFocus generate requests on focus event
➕ mutate(undefined, {forceRevalidate: true}) generates single request
➖ dedupingInterval filters requests within nms time span
➖ revalidateDebounce delays requests for nms
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:
ttl should 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 after ttl expired.
revalidateOnFocus should be a time span: "auto revalidate when window gets focused after interval in milliseconds.
refreshWithoutFocus = true option 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!
The text was updated successfully, but these errors were encountered:
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 everyn
msrevalidateOnFocus
generate requests on focus eventmutate(undefined, {forceRevalidate: true})
generates single requestdedupingInterval
filters requests withinn
ms time spanrevalidateDebounce
delays requests forn
msEspecially 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:
ttl
should 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 afterttl
expired.revalidateOnFocus
should be a time span: "auto revalidate when window gets focused after interval in milliseconds.refreshWithoutFocus = true
option 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!
The text was updated successfully, but these errors were encountered: