Last active
December 23, 2019 13:59
-
-
Save alexpermiakov/8c30b085a3ae82f222ef4e2c6aae9251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener("fetch", e => { | |
e.respondWith(getResponseByRequest(e.request)); | |
}); | |
const getResponseByRequest = async request => { | |
const cache = await caches.open(CACHE_NAME); | |
const cachedResponse = await cache.match(request); | |
return cachedResponse || fetch(request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment