CacheConfig
Defined in: src/policies/traffic/cache.ts:155
Configuration for the cache policy.
Extends
Section titled “Extends”Properties
Section titled “Properties”bypassDirectives?
Section titled “bypassDirectives?”
optionalbypassDirectives:string[]
Defined in: src/policies/traffic/cache.ts:173
Cache-Control directives that trigger a bypass. Matched at the directive level, not substring. Default: ["no-store", "no-cache"].
cacheableStatuses?
Section titled “cacheableStatuses?”
optionalcacheableStatuses:number[]
Defined in: src/policies/traffic/cache.ts:163
Only cache responses with these status codes. When set, responses with other statuses are not cached (5xx is always excluded regardless).
cacheKeyFn()?
Section titled “cacheKeyFn()?”
optionalcacheKeyFn: (c) =>string|Promise<string>
Defined in: src/policies/traffic/cache.ts:161
Custom cache key builder. Supports async for body-based keys. Default: method + url (+ body hash for POST/PUT/PATCH).
Parameters
Section titled “Parameters”Context
Returns
Section titled “Returns”string | Promise<string>
cacheStatusHeader?
Section titled “cacheStatusHeader?”
optionalcacheStatusHeader:string
Defined in: src/policies/traffic/cache.ts:171
Response header name for cache status (HIT/MISS/BYPASS/SKIP). Default: "x-cache".
methods?
Section titled “methods?”
optionalmethods:string[]
Defined in: src/policies/traffic/cache.ts:159
HTTP methods to cache. Default: [“GET”]. Case-insensitive.
respectCacheControl?
Section titled “respectCacheControl?”
optionalrespectCacheControl:boolean
Defined in: src/policies/traffic/cache.ts:169
Respect upstream Cache-Control directives. Default: true.
skip()?
Section titled “skip()?”
optionalskip: (c) =>boolean|Promise<boolean>
Defined in: src/policies/types.ts:90
Skip this policy when condition returns true
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean | Promise<boolean>
Inherited from
Section titled “Inherited from”store?
Section titled “store?”
optionalstore:CacheStore
Defined in: src/policies/traffic/cache.ts:167
Storage backend. Default: InMemoryCacheStore.
ttlSeconds?
Section titled “ttlSeconds?”
optionalttlSeconds:number
Defined in: src/policies/traffic/cache.ts:157
Cache TTL in seconds. Default: 300.
varyHeaders?
Section titled “varyHeaders?”
optionalvaryHeaders:string[]
Defined in: src/policies/traffic/cache.ts:165
Vary cache key on these request headers.