shellphone.app/app/service-worker/fetch.ts

27 lines
506 B
TypeScript
Raw Normal View History

import {
fetchAsset,
fetchDocument,
fetchLoaderData,
isAssetRequest,
isDocumentGetRequest,
isLoaderRequest,
} from "./cache-utils";
2022-06-04 13:48:37 +00:00
declare const self: ServiceWorkerGlobalScope;
2022-06-01 21:56:37 +00:00
export default async function handleFetch(event: FetchEvent) {
if (isAssetRequest(event.request)) {
return fetchAsset(event);
2022-06-01 21:56:37 +00:00
}
if (isLoaderRequest(event.request)) {
return fetchLoaderData(event);
}
if (isDocumentGetRequest(event.request)) {
return fetchDocument(event);
}
2022-06-01 21:56:37 +00:00
return fetch(event.request);
}