Remove screenshots from SW Cache

This commit is contained in:
Fred Boniface 2024-07-12 19:53:45 +01:00
parent 4526cfa3e0
commit 78fc63fe29
2 changed files with 10 additions and 1 deletions

View File

@ -6,10 +6,18 @@ const cacheName = `ob-${version}`;
const assets = [...build, ...files, "/service-worker.js"]; const assets = [...build, ...files, "/service-worker.js"];
const excludePatterns = [
"/static/images/screnshots/",
"/images/screenshots",
];
self.addEventListener("install", (event) => { self.addEventListener("install", (event) => {
async function addToCache() { async function addToCache() {
const cache = await caches.open(cacheName); const cache = await caches.open(cacheName);
await cache.addAll(assets); const assetsToCache = assets.filter(asset => {
return !excludePatterns.some(pattern => asset.startsWith(pattern));
});
await cache.addAll(assetsToCache);
} }
event.waitUntil(addToCache()); event.waitUntil(addToCache());

View File

@ -1,3 +1,4 @@
import adapter from "@sveltejs/adapter-static"; import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/kit/vite"; import { vitePreprocess } from "@sveltejs/kit/vite";