CacheControlCacheResolver

class CacheControlCacheResolver(maxAgeProvider: MaxAgeProvider, delegateResolver: CacheResolver = FieldPolicyCacheResolver) : CacheResolver

A cache resolver that raises a cache miss if the field's received date is older than its max age (configurable via maxAgeProvider) or if its expiration date has passed.

Received dates are stored by calling storeReceiveDate(true) on your ApolloClient.

Expiration dates are stored by calling storeExpirationDate(true) on your ApolloClient.

A maximum staleness can be configured via the ApolloCacheHeaders.MAX_STALE cache header.

Parameters

maxAgeProvider

the provider for the max age of fields

delegateResolver

the resolver to delegate to for non-stale fields, by default FieldPolicyCacheResolver

See also

Constructors

Link copied to clipboard
constructor(delegateResolver: CacheResolver = FieldPolicyCacheResolver)

Creates a new CacheControlCacheResolver with no max ages. Use this constructor if you want to consider only the expiration dates.

constructor(maxAgeProvider: MaxAgeProvider, delegateResolver: CacheResolver = FieldPolicyCacheResolver)

Functions

Link copied to clipboard
open override fun resolveField(context: ResolverContext): Any?

Resolves a field from the cache. Called when reading from the cache, usually before a network request.