forked from deriv-com/SmartCharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
34 lines (31 loc) · 893 Bytes
/
sw.js
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
var cacheName = 'SmartCharts';
var filesToCache = [
'./index.html',
'./dist/smartcharts.css',
'./dist/babel-polyfill.min.js',
'./dist/chartiq.min.js',
'./dist/react.js',
'./dist/react-dom.js',
'./dist/react-transition-group.js',
'./dist/mobx.js',
'./dist/mobx-react.js',
'./dist/smartcharts.js'
];
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll(filesToCache);
})
);
});
self.addEventListener('activate', function(event){
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', function(event){
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {return;}
event.respondWith(
caches.match(event.request, {ignoreSearch:true}).then(function(response){
return response || fetch(event.request);
})
);
});