Skip to content

CacheConfig

Defined in: src/policies/traffic/cache.ts:121

Configuration for the cache policy.

optional bypassDirectives: 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"].


optional cacheableStatuses: 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).


optional cacheKeyFn: (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).

Context

string | Promise<string>


optional cacheStatusHeader: string

Defined in: src/policies/traffic/cache.ts:137

Response header name for cache status (HIT/MISS/BYPASS/SKIP). Default: "x-cache".


optional methods: string[]

Defined in: src/policies/traffic/cache.ts:125

HTTP methods to cache. Default: [“GET”]. Case-insensitive.


optional respectCacheControl: boolean

Defined in: src/policies/traffic/cache.ts:135

Respect upstream Cache-Control directives. Default: true.


optional skip: (c) => boolean | Promise<boolean>

Defined in: src/policies/types.ts:33

Skip this policy when condition returns true

unknown

boolean | Promise<boolean>

PolicyConfig.skip


optional store: CacheStore

Defined in: src/policies/traffic/cache.ts:133

Storage backend. Default: InMemoryCacheStore.


optional ttlSeconds: number

Defined in: src/policies/traffic/cache.ts:123

Cache TTL in seconds. Default: 300.


optional varyHeaders: string[]

Defined in: src/policies/traffic/cache.ts:131

Vary cache key on these request headers.