---
title: TransactionInsertOptions
summary: Options for transactional cache insertions.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/cache/interface.TransactionInsertOptions/
---

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

Options for transactional cache insertions.

## Properties

### maxAge

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

Sets the "time to live" for the cache item in milliseconds: The time for which the item will be considered fresh.

### vary

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

Sets the list of headers that must match when looking up this cached item.

### initialAge

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

Sets the initial age of the cached item, in milliseconds, to be used in freshness calculations.

The initial age is 0 by default.

### staleWhileRevalidate

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

Sets the stale-while-revalidate period, in milliseconds for the cached item, which is the time for which the item can be safely used despite being considered stale.
Having a stale-while-revalidate period provides a signal that the cache should be updated (or its contents otherwise revalidated for freshness) asynchronously, while the stale cached item continues to be used, rather than blocking on updating the cached item.
The methods `CacheState.prototype.usable` and `CacheState.prototype.stale` can be used to determine the current state of an item.

The stale-while-revalidate period is 0 by default.

### surrogateKeys

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

Sets the surrogate keys that can be used for purging this cached item.
Surrogate key purges are the only means to purge specific items from the cache. At least one surrogate key must be set in order to remove an item without performing a purge-all, waiting for the item's TTL to elapse, or overwriting the item with insert().
Surrogate keys must contain only printable ASCII characters (those between 0x21 and 0x7E, inclusive). Any invalid keys will be ignored.

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

### length

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

Sets the size of the cached item, in bytes, when known prior to actually providing the bytes.
It is preferable to provide a length, if possible.
Clients that begin streaming the item's contents before it is completely provided will see the promised length which allows them to, for example, use content-length instead of transfer-encoding: chunked if the item is used as the body of a Request or Response.

### userMetadata

**Type:** `ArrayBufferView | ArrayBuffer | URLSearchParams | string`  
**Flags:** optional  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/cache.d.ts#L216

Sets the user-defined metadata to associate with the cached item.

### sensitive

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

Enable or disable PCI/HIPAA-compliant non-volatile caching.
By default, this is false.

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