shellphone.app/app/service-worker/fetch.ts
m5r 1e9b7a8aa2 * fix "dev:build" watch mode
* remove cross-env
* append build hash to service worker cache names for easy purge
2022-06-11 15:13:28 +02:00

27 lines
506 B
TypeScript

import {
fetchAsset,
fetchDocument,
fetchLoaderData,
isAssetRequest,
isDocumentGetRequest,
isLoaderRequest,
} from "./cache-utils";
declare const self: ServiceWorkerGlobalScope;
export default async function handleFetch(event: FetchEvent) {
if (isAssetRequest(event.request)) {
return fetchAsset(event);
}
if (isLoaderRequest(event.request)) {
return fetchLoaderData(event);
}
if (isDocumentGetRequest(event.request)) {
return fetchDocument(event);
}
return fetch(event.request);
}