aboutsummaryrefslogtreecommitdiffstats
path: root/sworker.js
blob: e04691c74091477c1b3ee9a884101759451e6227 (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
44
45
46
47
48
49
50
51
52
53
var version = 'v2 - 2011-11-16';
var toCache = [
  '/',
  'index.html',
  'activePage.js',
  'activePage.js.map',
  'config.js',
  'config.js.map',
  'hesla.js',
  'hesla.js.map',
  'hesla.webapp',
  'require.js',
  'favicon.ico',
  'icon-128.png',
  'icon-30.png',
  'icon-60.png',
  'index_de.html',
  'index.html',
  'require.js',
  'screen.css'
];
 
self.addEventListener('install', event => {
  event.waitUntil(
    caches.open('static' + version).then(c => c.addAll(toCache))
  );
});

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

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

// this.addEventListener('fetch', function(event) {
//   event.respondWith(
//     caches.match(event.request).then(function(pro) {
//       console.log('Fullfilling ' + event.request.url + ' from cache');
//       return pro;
//     }).catch(function() {
//       console.log('Loading ' + event.request.url);
//       return fetch(event.request);
//     })
//   );
// });