Skip to content

Instantly share code, notes, and snippets.

@jacky810124
Created March 29, 2018 06:46
Show Gist options
  • Save jacky810124/f86dc8db0406451648e461e2f4aeedec to your computer and use it in GitHub Desktop.
Save jacky810124/f86dc8db0406451648e461e2f4aeedec to your computer and use it in GitHub Desktop.
PWA Day06 - cache then network
// 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