Configures the caching behavior of a Response.

Normally, the HTTP Headers on a Response would control how the Response is cached, but CacheOverride can be set on a Request, to define custom caching behavior.

Example

In this example we override the cache for all the requests prefixed /static/ to have a long TTL (Time To Live), and the home page to have a short TTL and a long SWR (Stale While Revalidate).

Hierarchy

  • CacheOverride

Constructors

Properties

Constructors

  • Parameters

    • mode: "none" | "pass" | "override"

      Sets the cache override mode for a request

      If set to:

      • "none": Do not override the behavior specified in the origin response’s cache control headers.
      • "pass": Do not cache the response to this request, regardless of the origin response’s headers.
      • "override": Override particular cache control settings using a CacheOverride object.
    • Optional init: {
          pci?: boolean;
          surrogateKey?: string;
          swr?: number;
          ttl?: number;
      }
      • Optional pci?: boolean

        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 for details.

      • Optional surrogateKey?: string

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

        See the Fastly surrogate keys guide for details.

      • Optional swr?: number

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

      • Optional ttl?: number

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

    Returns CacheOverride

Properties

mode: "none" | "pass" | "override"

Sets the cache override mode for a request

If set to:

  • "none": Do not override the behavior specified in the origin response’s cache control headers.
  • "pass": Do not cache the response to this request, regardless of the origin response’s headers.
  • "override": Override particular cache control settings using a CacheOverride object.
pci?: boolean

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 for details.

surrogateKey?: string

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

See the Fastly surrogate keys guide for details.

swr?: number

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

ttl?: number

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

Generated using TypeDoc