-
Notifications
You must be signed in to change notification settings - Fork 673
Support CacheAndNetwork
Option in the HttpCache
#4235
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
Comments
Does this mean that we'll be receiving data by using |
@naveenfunk yes that would make sense and is already the case when using |
Thanks. when are you guys planning on taking this feature request or should i check Normalized cache for achieving this
behaviour ? |
@naveenfunk the normalized cache already has |
@BoD One more question. I tried NETWORK_FIRST http cache policy and it doesn't seems to get cached data when i turn internet connection off. the app never gets callback from apollo lib and the app stucks on loading state. |
Hi @naveenfunk, this should work. One thing I can think of is sometimes it takes a while before the network stack is seen as offline (I've noticed it in particular with the emulator). In any case if you can reproduce it systematically, mind opening a specific ticket with more details? Thanks! |
Thanks @BoD . It works better in real device. If needed will surely create a ticket. Thanks a lot man |
Use case
To replicate the convenient functionality of using the normalized cache, the
HttpCache
should also support this option. Currently, it only supportsCacheFirst
, orNetworkFirst
, which means we only ever receive one response, if its in the cache.Currently, what this means, is if, we use
HttpCache
without a timeout specified, the cache never expires. It never hits the network again after it receives the initial response, unless I set an explicit timeout. I'd certainly like to cache the previous output and still reach out for the latest - this way the UI can reactively update if the data changes in any meaningful way.A workaround is to send two queries - 1 for initial cache, then a second one with cache disabled on that request.
Describe the solution you'd like
Ideally, using
watch()
on our queries, we could receive multiple results. 1 for cache (if it exists), then 1 for the network (if we have a network connection).Add the
CacheAndNetwork
option to theHttpFetchPolicy
. Optionally, merge the two enums so they are both equally supported in each cache type.The text was updated successfully, but these errors were encountered: