Closed
Description
Question
Consider this chain of events
- A query is already cached in the HTTP Cache
- It is successfully read from it with a cache first policy
- It is executed again with a network only fetch policy, and fails because there is no internet
- Then executed again with a cache first policy
I would expect it to still be in the cache, but when this scenario happens in my case, the query is no longer there and I am getting a cache miss exception.
After investigating, I found that HttpCacheApolloInterceptor
removes queries from cache when the response was unsuccessful (has GQL errors or exceptions). However, looking at the code for CachingHttpInterceptor
, the network fetch networkMightThrow
function calls chain.proceed(request)
first thing, which would throw a network exception when there is no internet, so the rest of networkMightThrow
, the part that puts the response in the cache, won't get called (from what I understand).
Is removing the cached query response in cases like these intentional?