Last active
March 12, 2018 00:13
-
-
Save ritikrishu/c0ab94889bc5603365e13e964e43a188 to your computer and use it in GitHub Desktop.
respond with static files from cache only.
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
//no network call is made, only local store is looked into | |
self.addEventListener('fetch', function (event) { | |
const requestUrl = new URL(event.request.url); | |
if(myItemsToPrefetchRequestArray.contains(requestUrl){ | |
event.respondWith( | |
caches.open(staticCacheName).then( | |
cache => cache.match(event.request) | |
) | |
) | |
return; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment