Skip to content

Precedence of fetching conditions #344

@memen45

Description

@memen45

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions