1- var cacheName = 'csswizardry:0003 ' ;
1+ var cacheName = 'csswizardry:0005 ' ;
22var cacheFiles = [
33 '/' ,
44 '/about/' ,
55 '/services/' ,
66 '/contact/' ,
7- '/offline/' ,
7+ '/case-studies/' ,
8+ '/case-studies/raspberry-pi-code-club-workshop/' ,
9+ '/case-studies/ocado-workshop/' ,
10+ '/case-studies/nhs-nhsx-elearning-platform/' ,
11+ '/case-studies/better-collective/' ,
12+ '/case-studies/madgex-consultancy-workshop/' ,
13+ '/case-studies/bbc-workshop/' ,
14+ '/case-studies/bskyb/' ,
15+ '/case-studies/css-wizardry/' ,
16+ '/case-studies/financial-times/' ,
817 '/2015/03/more-transparent-ui-code-with-namespaces/' ,
918 '/2015/08/bemit-taking-the-bem-naming-convention-a-step-further/' ,
1019 '/2016/02/mixins-better-for-performance/' ,
1120 '/2016/10/pragmatic-practical-progressive-theming-with-custom-properties/' ,
12- '/case-studies/ocado-workshop /'
21+ '/offline /'
1322] ;
1423
24+
25+
26+
27+
1528self . addEventListener ( 'install' , function ( event ) {
1629 event . waitUntil (
1730 caches . open ( cacheName )
@@ -22,6 +35,10 @@ self.addEventListener('install', function(event) {
2235 ) ;
2336} ) ;
2437
38+
39+
40+
41+
2542self . addEventListener ( 'fetch' , function ( event ) {
2643 event . respondWith (
2744 caches . match ( event . request )
@@ -37,3 +54,25 @@ self.addEventListener('fetch', function(event) {
3754 } )
3855 ) ;
3956} ) ;
57+
58+
59+
60+
61+
62+ // Empty out any caches that don’t match the ones listed.
63+ self . addEventListener ( 'activate' , function ( event ) {
64+
65+ var cacheWhitelist = [ 'csswizardry:0005' ] ;
66+
67+ event . waitUntil (
68+ caches . keys ( ) . then ( function ( cacheNames ) {
69+ return Promise . all (
70+ cacheNames . map ( function ( cacheName ) {
71+ if ( cacheWhitelist . indexOf ( cacheName ) === - 1 ) {
72+ return caches . delete ( cacheName ) ;
73+ }
74+ } )
75+ ) ;
76+ } )
77+ ) ;
78+ } ) ;
0 commit comments