Skip to content

Is HTTP Cache supposed to evict cached queries when the same query is exectued again and results in network failure? #6313

Closed
@Emplexx

Description

@Emplexx

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions