Skip to content

HttpCache configuration #5878

Closed as not planned
Closed as not planned
@kapilsukhyani

Description

@kapilsukhyani

Question

Can an HTTP cache be shared for multiple ApolloClient instances?

Although the cache policy that we have for now is NetworkOnly, it seems like the queries do get written to the cache respectively here.

Right now we have two clients using the same cache with same cache policy of NetworkOnly but we do see issues with cache where the tmp cache file is sometimes not found, and my assumption here is, that it probably is because of the same cache being used, where a query execution through one client might delete the same file as being used by the other client.

java.io.FileNotFoundException: ..../cache/apolloCache/journal.tmp -> ..../cache/apolloCache/journal
    at okio.NioSystemFileSystem.atomicMove(NioSystemFileSystem.kt:80)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCacheKt.rename(DiskLruCache.kt:1019)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCacheKt.access$rename(DiskLruCache.kt:1)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCache.rebuildJournal(DiskLruCache.kt:371)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCache.initialize(DiskLruCache.kt:225)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCache.edit(DiskLruCache.kt:410)
    at com.apollographql.apollo3.cache.http.internal.DiskLruCache.edit(DiskLruCache.kt:404)
    at com.apollographql.apollo3.cache.http.DiskLruHttpCache.write(DiskLruHttpCache.kt:58)
    at com.apollographql.apollo3.cache.http.CachingHttpInterceptor.networkMightThrow(CachingHttpInterceptor.kt:112)
    at com.apollographql.apollo3.cache.http.CachingHttpInterceptor.intercept(CachingHttpInterceptor.kt:57)
    at com.apollographql.apollo3.network.http.DefaultHttpInterceptorChain.proceed(HttpInterceptor.kt:22)
    at com.apollographql.apollo3.cache.http.HttpCache$httpCache$1.intercept(HttpCacheExtensions.kt:87)
    at com.apollographql.apollo3.network.http.DefaultHttpInterceptorChain.proceed(HttpInterceptor.kt:22)
    at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invokeSuspend(HttpNetworkTransport.kt:65)
    at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(HttpNetworkTransport.kt:0)
    at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(HttpNetworkTransport.kt:0)
    at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(HttpNetworkTransport.kt:0)
    at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(HttpNetworkTransport.kt:0)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions