Cache only index page, not all documents

This commit is contained in:
Kieran 2023-08-19 23:00:02 +01:00
parent 0cb56870a4
commit 42a3bdca68
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -7,9 +7,11 @@ import { CacheFirst } from "workbox-strategies";
clientsClaim();
const staticTypes = ["image", "video", "audio", "script", "style", "font", "document"];
const staticTypes = ["image", "video", "audio", "script", "style", "font"];
const paths = ["/"];
registerRoute(
({ request, url }) => url.origin === self.location.origin && staticTypes.includes(request.destination),
({ request, url }) =>
url.origin === self.location.origin && (staticTypes.includes(request.destination) || paths.includes(url.pathname)),
new CacheFirst({
cacheName: "static-content",
})