Created
January 12, 2018 21:12
-
-
Save devNoiseConsulting/f856c42f3da77364a7b080cbf0c22660 to your computer and use it in GitHub Desktop.
Pay attention to which variable you're using!
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
| // Wrong!!! | |
| self.addEventListener('activate', function(event) { | |
| var cacheWhitelist = ['v2']; | |
| event.waitUntil( | |
| // TODO: remove the old cache | |
| caches.keys().then(function(keyList) { | |
| return Promise.all( | |
| keyList.map(function(key) { | |
| if (cacheWhitelist.indexOf(key) === -1) { | |
| console.log(key); | |
| return caches.delete(key); | |
| } | |
| }) | |
| ); | |
| }) | |
| ); | |
| }); | |
| // Right! | |
| self.addEventListener('activate', function(event) { | |
| var cacheWhitelist = ['v2']; | |
| event.waitUntil( | |
| // TODO: remove the old cache | |
| caches.keys().then(function(keyList) { | |
| return Promise.all( | |
| keyList.map(function(key) { | |
| if (key.indexOf(cacheWhitelist) === -1) { | |
| return caches.delete(key); | |
| } | |
| }) | |
| ); | |
| }) | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment