Constructor

CacheableResponse

new CacheableResponse(config)

To construct a new CacheableResponse instance you must provide at least one of the config properties.

If both statuses and headers are specified, then both conditions must be met for the Response to be considered cacheable.

Parameter

config

Object

Values in config have the following properties:

Parameter

statuses

Optional

Array of number

One or more status codes that a Response can have and be considered cacheable.

headers

Optional

Object with string properties

A mapping of header names and expected values that a Response can have and be considered cacheable. If multiple headers are provided, only one needs to be present.

Method

isResponseCacheable

isResponseCacheable(response) returns boolean

Checks a response to see whether it's cacheable or not, based on this object's configuration.

Parameter

response

Response

The response whose cacheability is being checked.

Returns

boolean true if the Response is cacheable, and false otherwise.