RetrostashOkHttpInterceptor

class RetrostashOkHttpInterceptor(engine: RetrostashEngine, config: RetrostashOkHttpConfig = RetrostashOkHttpConfig()) : <ERROR CLASS> ERROR CLASS: Symbol not found for Interceptor

OkHttp Interceptor that powers @CacheQuery / @CacheMutate semantics.

Reads metadata from the request via either:

On a query: short-circuits to a synthetic Response built from the cached payload when the key resolves and the entry is fresh.

On a mutation: forwards the call to the network, then on 2xx resolves OkHttpRetrostashMetadata.invalidateTemplates against bindings and invalidates each.

Mutation responses are tagged with Cache-Control: no-store so OkHttp's own HTTP cache (if one is configured on the client) does not retain mutation payloads. GET responses are passed through unchanged — Retrostash does not modify GET Cache-Control headers; that's between the origin and OkHttp's HTTP cache.

The synthetic cache-hit response carries a custom X-Retrostash-Source header so callers can distinguish hit/miss without inspecting the cache directly. Possible values:

  • retrostash-cache — served from Retrostash's store.

  • okhttp-cache — served from OkHttp's HTTP cache (Retrostash store missed). Retrostash invalidation does not reach OkHttp HTTP cache; see Caching strategy.

  • okhttp-validated-cache — OkHttp HTTP cache hit revalidated with the network.

  • network — fresh network response.

Constructors

Link copied to clipboard
constructor(engine: RetrostashEngine, config: RetrostashOkHttpConfig = RetrostashOkHttpConfig())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun intercept(chain: ERROR CLASS: Symbol not found for Interceptor.Chain): ERROR CLASS: Symbol not found for Response