---
title: CacheOptions
summary: Cache customization options for responses, provided through the afterSend hook.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/cache-override/interface.CacheOptions/
---

**Kind:** Interface  
**Module:** [cache-override](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/cache-override/)  
**Package:** @fastly/js-compute 4.0.1  
**Since:** 3.30.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L10

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

**Type:** `boolean | 'uncacheable'`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L28

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](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/request-collapsing/)
for more details on the mechanism that `uncacheable` disables.

### bodyTransformFn

**Type:** `(body: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer> | PromiseLike<Uint8Array<ArrayBuffer>>`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L41

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.
