Urara-Blog/node_modules/.pnpm-store/v3/files/a1/4f2d77fde7b2bd4b0f56b6b7e58d6588ad7b7c2006b96a18a998dba1af7aacc2b032577fdaab1fc41b4d275e7a2030d695d1561807a40ed74fcb75addc5532
2022-08-14 01:14:53 +08:00

47 lines
1.2 KiB
Text

/// <reference lib="webworker" />
import type { Context, Params } from 'worktop';
import type { Strict } from 'worktop/utils';
/**
* Determine if the Response can be cached.
*/
export function isCacheable(
response: Response
): boolean;
/**
* Cache a Response for the given request.
* @NOTE A `request` string is treated as a `GET` request.
*/
export function save(
cache: Cache,
request: Request | string,
response: Response,
context: {
waitUntil(f: any): void;
}
): Response;
/**
* Attempt to retrieve a cached Response for the request.
* @NOTE A `request` string is treated as a `GET` request.
*/
export function lookup(
cache: Cache,
request: Request | string
): Promise<Response | void>;
/**
* Return a `Handler` that will `lookup` incoming requests and `save` outgoing Responses.
* If a request has a cached Response, it will be returned. Otherwise this method will
* wait for a `Response` and assign it to the request for next lookup.
*/
export function sync(
cache: Cache
): <C extends Context = Context, P extends Params = Params>(
request: Request,
context: Omit<C, 'params'> & {
params: Strict<P & C['params']>;
}
) => Response|void;