summaryrefslogtreecommitdiffstats
path: root/sworker.js
blob: 54d6955d4622afda2efec48ae6e95bd38d442bb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var version = 'v41 2016-11-15';
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));
});