CacheConfig
Defined in: src/policies/traffic/cache.ts:121
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:139
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:129
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:127
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:137
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:125
HTTP methods to cache. Default: [“GET”]. Case-insensitive.
respectCacheControl?
Section titled “respectCacheControl?”
optionalrespectCacheControl:boolean
Defined in: src/policies/traffic/cache.ts:135
Respect upstream Cache-Control directives. Default: true.
skip()?
Section titled “skip()?”
optionalskip: (c) =>boolean|Promise<boolean>
Defined in: src/policies/types.ts:33
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:133
Storage backend. Default: InMemoryCacheStore.
ttlSeconds?
Section titled “ttlSeconds?”
optionalttlSeconds:number
Defined in: src/policies/traffic/cache.ts:123
Cache TTL in seconds. Default: 300.
varyHeaders?
Section titled “varyHeaders?”
optionalvaryHeaders:string[]
Defined in: src/policies/traffic/cache.ts:131
Vary cache key on these request headers.