-
Notifications
You must be signed in to change notification settings - Fork 658
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
Initial implementation of cache control #3566
Comments
About the directive: would it make sense for it to be |
When discussing the declarative cache directives, we decided to not reuse the federation I think it's safer to do that assumption here as well. That being said, I don't have any strong opinions about naming at this stage. This was more of a placeholder than anything else. |
Oh interesting! Makes sense! |
Updated the initial description after the #3709 discussion. |
#4104 and #4156 introduce a new (experimental) SQLite cache backend (named Client driven: val client = ApolloClient.Builder()
.normalizedCache(
normalizedCacheFactory = SqlNormalizedCacheFactory(name = fileName, withDates = true),
cacheKeyGenerator = TypePolicyCacheKeyGenerator,
cacheResolver = ReceiveDateCacheResolver(maxAge)
)
.storeReceiveDate(true)
.serverUrl("https://...")
.build() Server driven: val apolloClient = ApolloClient.Builder()
.normalizedCache(
normalizedCacheFactory = SqlNormalizedCacheFactory(name = fileName, withDates = true),
cacheKeyGenerator = TypePolicyCacheKeyGenerator,
cacheResolver = ExpireDateCacheResolver()
)
.storeExpirationDate(true)
.serverUrl("https://...")
.build() Cache resolver APIBoth these APIs leverage the Follow upI'm going to close this issue as it was quite broad and follow up in more focused ones: |
@martinbonnin follow-up question on this, If i were to use the |
I would say so. The All in all, I like to think of the One question you will bump into if you're planning to use the |
When using the normalized cache, it should be possible to expire data:
There are currently very little options for this
HttpCache
has "CACHE_EXPIRE_TIMEOUT_HEADER" which is client controlled and doesn't read the server valueMemoryCache
has "expireAfterMillis" which is client controlled and doesn't read the server value (and works at the Record level)SqlNormalizedCache
has no expirationtentative API
By default, the
maxAge
should come from the server. Given this response:A client requesting this data after 60s will fail from cache and fallback to the network:
It should be possible to override the maxAge from the client when getting the data:
Or programmatically on the store itself:
Because some stale data is better than nothing, the cache should be configured with a maxSize and not remove entries immediately:
This way, a client can use stale data if it wants to:
Client-side expiration logic
If the server didn't send any cache information, we could think of "hardcoding" the rules in the client:
Or that could be a runtime thing too:
I'm not too sold on that idea yet because that adds friction between the client and the server but that'd be a way to communicate per-field cache information out of band.
Related work:
Part of #2331
The text was updated successfully, but these errors were encountered: