| 1 | import './_version.js';
|
|---|
| 2 | export interface CacheableResponseOptions {
|
|---|
| 3 | statuses?: number[];
|
|---|
| 4 | headers?: {
|
|---|
| 5 | [headerName: string]: string;
|
|---|
| 6 | };
|
|---|
| 7 | }
|
|---|
| 8 | /**
|
|---|
| 9 | * This class allows you to set up rules determining what
|
|---|
| 10 | * status codes and/or headers need to be present in order for a
|
|---|
| 11 | * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|---|
| 12 | * to be considered cacheable.
|
|---|
| 13 | *
|
|---|
| 14 | * @memberof workbox-cacheable-response
|
|---|
| 15 | */
|
|---|
| 16 | declare class CacheableResponse {
|
|---|
| 17 | private readonly _statuses?;
|
|---|
| 18 | private readonly _headers?;
|
|---|
| 19 | /**
|
|---|
| 20 | * To construct a new CacheableResponse instance you must provide at least
|
|---|
| 21 | * one of the `config` properties.
|
|---|
| 22 | *
|
|---|
| 23 | * If both `statuses` and `headers` are specified, then both conditions must
|
|---|
| 24 | * be met for the `Response` to be considered cacheable.
|
|---|
| 25 | *
|
|---|
| 26 | * @param {Object} config
|
|---|
| 27 | * @param {Array<number>} [config.statuses] One or more status codes that a
|
|---|
| 28 | * `Response` can have and be considered cacheable.
|
|---|
| 29 | * @param {Object<string,string>} [config.headers] A mapping of header names
|
|---|
| 30 | * and expected values that a `Response` can have and be considered cacheable.
|
|---|
| 31 | * If multiple headers are provided, only one needs to be present.
|
|---|
| 32 | */
|
|---|
| 33 | constructor(config?: CacheableResponseOptions);
|
|---|
| 34 | /**
|
|---|
| 35 | * Checks a response to see whether it's cacheable or not, based on this
|
|---|
| 36 | * object's configuration.
|
|---|
| 37 | *
|
|---|
| 38 | * @param {Response} response The response whose cacheability is being
|
|---|
| 39 | * checked.
|
|---|
| 40 | * @return {boolean} `true` if the `Response` is cacheable, and `false`
|
|---|
| 41 | * otherwise.
|
|---|
| 42 | */
|
|---|
| 43 | isResponseCacheable(response: Response): boolean;
|
|---|
| 44 | }
|
|---|
| 45 | export { CacheableResponse };
|
|---|