Created
March 29, 2018 06:46
-
-
Save jacky810124/f86dc8db0406451648e461e2f4aeedec to your computer and use it in GitHub Desktop.
PWA Day06 - cache then network
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
// Here is the code in the sw.js: | |
self.addEventListener('fetch', function(event) { | |
event.respondWith( | |
caches | |
.open('mysite-dynamic') | |
.then(function(cache) { | |
return fetch(event.request) | |
.then(function(response) { | |
cache.put(event.request, response.clone()) | |
return response | |
}) | |
}) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment