Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precedence of fetching conditions #344

Open
memen45 opened this issue Apr 11, 2023 · 0 comments
Open

Precedence of fetching conditions #344

memen45 opened this issue Apr 11, 2023 · 0 comments

Comments

@memen45
Copy link

memen45 commented Apr 11, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant