Skip to content

Instantly share code, notes, and snippets.

@jimwhimpey
Created August 27, 2019 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimwhimpey/1914c47db89daef372c553fa437dc09c to your computer and use it in GitHub Desktop.
Save jimwhimpey/1914c47db89daef372c553fa437dc09c to your computer and use it in GitHub Desktop.
self.addEventListener('fetch', (e) => {
if (assetManifest.includes(e.request.url) {
e.respondWith(
caches
.open(cacheKey)
.then(cache => cache.match(e.request))
.then(response => {
if (response) return response;
return fetch(e.request);
});
);
} else {
e.respondWith(fetch(e.request));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment