serwist
Version:
A Swiss Army knife for service workers.
40 lines • 1.44 kB
TypeScript
export interface CacheableResponseOptions {
/**
* One or more HTTP status codes that a response can have to be considered cacheable.
*/
statuses?: number[];
/**
* 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.
*/
headers?: HeadersInit;
}
/**
* Allows you to set up rules determining what status codes and/or headers need
* to be present in order for a [response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
* to be considered cacheable.
*/
export declare class CacheableResponse {
private readonly _statuses?;
private readonly _headers?;
/**
* 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.
*
* @param config
*/
constructor(config?: CacheableResponseOptions);
/**
* Checks a response to see whether it's cacheable or not.
*
* @param response The response whose cacheability is being
* checked.
* @returns `true` if the response is cacheable, and `false`
* otherwise.
*/
isResponseCacheable(response: Response): boolean;
}
//# sourceMappingURL=CacheableResponse.d.ts.map