CacheOptions

Interfacein cache-override@fastly/js-compute 4.0.0since 3.30.0View source

Cache customization options for responses, provided through the afterSend hook.

For customizing the response status, headers, and other cache options, these can be modified directly on the response.

Properties

cache

boolean | 'uncacheable'optionalView source

Whether to cache this response.

By default, leaving this field empty, responses will be cached based on their cache header information.

Setting this to true or false will override this default cache behaviour, setting in the cache or not setting in the cache, even if the default behaviour would have been otherwise.

Setting to 'uncacheable' the response will not only not be cached, but the cache will record that the originating request led to an uncacheable response, so that future cache lookups will result in immediately going to the backend, rather than attempting to coordinate concurrent requests to reduce backend traffic.

See the Fastly request collapsing guide for more details on the mechanism that uncacheable disables.

bodyTransformFn

(body: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer> | PromiseLike<Uint8Array<ArrayBuffer>>optionalView source

Provide a function to be used for transforming the response body prior to caching.

Body transformations are performed by specifying a transform, rather than by directly working with the body during the onAfterSend callback function, because not every response contains a fresh body: 304 Not Modified responses, which are used to revalidate a stale cached response, are valuable precisely because they do not retransmit the body.

For any other response status, the backend response will contain a relevant body, and the bodyTransformFn will be applied to it. The original backend body is passed in to the transform function, and the function is expected to return the new body.