Skip to content
Snippets Groups Projects
Commit 6c65e193 authored by Ewen Le Bihan's avatar Ewen Le Bihan
Browse files

perf(service worker): make use of ASSETS cache

parent e67a6954
Branches
Tags v1.18.0
No related merge requests found
......@@ -113,15 +113,15 @@ sw.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') return;
const respond = async () => {
// const url = new URL(event.request.url);
const url = new URL(event.request.url);
const cache = await caches.open(CACHE);
// `build`/`files` can always be served from the cache
// if (ASSETS.includes(url.pathname)) {
// const response = await cache.match(url.pathname);
// if (response === undefined) throw new Error('Cache miss in build or files');
// return response;
// }
if (ASSETS.includes(url.pathname)) {
const response = await cache.match(url.pathname);
if (response === undefined) throw new Error('Cache miss in build or files');
return response;
}
// for everything else, try the network first, but
// fall back to the cache if we're offline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment