DEV Community

loading...

Discussion on: Sapper with "cache-first"

Collapse
anirudhkonduru profile image
Anirudh Konduru

This seems to be identical to the service-worker.js that comes with the sapper starter project, without the change required to make it cache-first.
An short fix for anyone looking for the solution: replace the try block in the very last few lines with this:

let response = await cache.match(event.request);
if (response) return response;
response = await fetch(event.request);
cache.put(event.request, response.clone());
return response;