diff --git a/assets/sw.js b/assets/sw.js index 87a3c28..09512f7 100644 --- a/assets/sw.js +++ b/assets/sw.js @@ -91,20 +91,17 @@ function cached(req) { async function answer(input, event) { const req = typeof input === 'string' ? new Request(input) : input; - try { - const res = await fromNetwork(req); - if (res && res.ok && res.type === 'basic') { - const copy = res.clone(); - const write = cacheFor(req).then((c) => c.put(req, copy)); - if (event) event.waitUntil(write); - else write.catch(() => {}); - } - return res; - } catch (err) { - const hit = await cached(req); - if (hit) return hit; - throw err; + const hit = await cached(req); + if (hit) return hit; + + const res = await fromNetwork(req); + if (res && res.ok && res.type === 'basic') { + const copy = res.clone(); + const write = cacheFor(req).then((c) => c.put(req, copy)); + if (event) event.waitUntil(write); + else write.catch(() => {}); } + return res; } function pageRequest(url) {