persistQueryClient removes cached entries if the network is down #2207
Unanswered
gabrielbull
asked this question in
Ideas
Replies: 1 comment 1 reply
-
Hey @gabrielbull , thanks for this, is this already working? I'm trying to use RQ as well for offline mode but once the device goes offline and the data gets stale, or when RQ tries to fetch data, or clears the data internally at some point idk, my whole app stops working offline due to I tried this approach but still the cache is cleared or invalidated or unused. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @tannerlinsley. This is sort of a follow up on my recent PR #2131. Currently, entries are removed from persisted cache when an error happens on a query, even a network error. One of the most common use case for persistQueryClient is to have offline support, which means all queries would have network errors. Using the PR I made, we can now pass dehydrateOptions and avoid the cache removing entries with code like this:
This is great and we can now effectively use persistQueryClient for offline support. But this begs the question, shouldn't something like that be the default behaviour for persistQueryClient. Why does persistQueryClient need to remove cached entries on errors anyway?
@makirby, can you tell us what was your use case for passing dehydrate/hydrate options to persistQueryClient?
Beta Was this translation helpful? Give feedback.
All reactions