summaryrefslogblamecommitdiffstats
path: root/sworker.js
blob: 869a1f0cd3886f8b28da809b02c025c8d5242a00 (plain) (tree)
1
                               

















                                
 
                                           






                                                                                            

   
                                            




                                                        
     

    
 
                                                

                                                 
var version = 'v40 2016-01-26';
var toCache = [
  '/',
  'activePage.js',
  'activePage.js.map',
  'config.js',
  'config.js.map',
  'zalmy.js',
  'zalmy.js.map',
  'zalmy.webapp',
  'require.js',
  'favicon.ico',
  'style/basic.css',
  'style/OpenSans-SemiBold.ttf',
  'style/icon-128.png',
  'style/icon-512.png',
  'style/icon-60.png',
  'style/icon-64.png'
];

self.addEventListener('install', event => {
    event.waitUntil(
      caches.open('static' + version)
      .then(
        c => c.addAll(toCache)
          .then(v => console.log('********* Yay!'), e => console.log('************* Error'))
      )
    );
});

self.addEventListener('activate', event => {
  event.waitUntil(caches.keys().then(
        keys => Promise.all(
          keys.filter(key => key != 'static' + version).
            map(key => caches.delete(key))
        )
    )
  );
});

self.addEventListener('fetch', function(event) {
  event.respondWith(caches.match(event.request));
});