Created
May 11, 2018 05:27
-
-
Save okjodom/cf2a6721466a328fc8b473c59b28b3b3 to your computer and use it in GitHub Desktop.
Offline first Using service workers, after coffee break, Yaay!
This file contains hidden or 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
| (coffee break).then( freshMind => { | |
| self.addEventListener('fetch', function (event) { | |
| // TODO: respond with an entry from the cache if there is one. | |
| // If there isn't, fetch from the network. | |
| event.respondWith( | |
| caches.open('wittr-static-v1').then(cache => { | |
| return cache.match(event.request).then(response => { | |
| if (!response) { | |
| return fetch(event.request); | |
| } | |
| return response; | |
| }); | |
| }) | |
| ); | |
| }); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment