---
title: ICacheOverride
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/cache-override/interface.ICacheOverride/
---

**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  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L55

## Properties

### ttl

**Type:** `number`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L59

Override the caching behavior of this request to use the given Time to Live (TTL), in seconds.

### swr

**Type:** `number`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L64

Override the caching behavior of this request to use the given `stale-while-revalidate` time,
in seconds.

### surrogateKey

**Type:** `string`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L72

Override the caching behavior of this request to include the given surrogate key, provided as
a header value.

See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
for details.

### pci

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

Override the caching behavior of this request to enable or disable PCI/HIPAA-compliant
non-volatile caching.

By default, this is false, which means the request may not be PCI/HIPAA-compliant. Set it to
true to enable compliant caching.

See the [Fastly PCI-Compliant Caching and Delivery documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery)
for details.

### beforeSend

**Type:** `(request: Request) => void | PromiseLike<void>`  
**Flags:** optional, since 3.30.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L96

Set a [callback function](https://developer.mozilla.org/en-US/docs/Glossary/Callback_function) to be invoked if a
request is going all the way to a backend, allowing the request to be modified beforehand.

See [Modifying a request as it is forwarded to a backend](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/#modifying-a-request-as-it-is-forwarded-to-a-backend)
in the Fastly cache interfaces documentation for details.

### afterSend

**Type:** `(response: Response) => void | CacheOptions | PromiseLike<void | CacheOptions>`  
**Flags:** optional, since 3.30.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache-override.d.ts#L109

Set a [callback function](https://developer.mozilla.org/en-US/docs/Glossary/Callback_function) to be invoked after
a response has been sent, but before it is stored into the cache.

See [Controlling cache behavior based on backend response](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/#controlling-cache-behavior-based-on-backend-response)
in the Fastly cache interfaces documentation for details.
