forked from kelvinkamau/Vibranium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
62 lines (62 loc) · 3.02 KB
/
service-worker.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
self.addEventListener('fetch', function (event) {
event.respondWith(caches.open('cache').then(function (cache) {
return cache.match(event.request).then(function (response) {
console.log("cache request: " + event.request.url);
var fetchPromise = fetch(event.request).then(function (networkResponse) {
console.log("fetch completed: " + event.request.url, networkResponse);
if (networkResponse) {
console.debug("updated cached page: " + event.request.url, networkResponse);
if (event.request.method === 'GET' && networkResponse.type === 'basic') {
cache.put(event.request, networkResponse.clone());
}
}
return networkResponse;
}, function (event) {
console.log("Error in fetch()", event);
event.waitUntil(
caches.open('cache').then(function (cache) {
return cache.addAll
([
'/',
'/index.html',
'/index.html?homescreen=1',
'/?homescreen=1',
'/css/bootstrap.min.css',
'/css/ionicons.min.css',
'/css/magnific-popup.css',
'/css/owl.carousel.min.css',
'/css/responsive.css',
'/css/styles.css',
'/css/swiper.min.css',
'/images/assets/events/fba.png',
'/images/assets/events/fbw.png',
'/images/assets/events/rpj.png',
'/images/assets/hero-1-2.png',
'/images/assets/logo2.png',
'/images/assets/team/avatar.png',
'/images/assets/technologies/android.png',
'/images/assets/technologies/cloud.png',
'/images/assets/technologies/mi.png',
'/images/assets/technologies/web.png',
'/images/icon.png',
'/js/custom.js',
'/js/vendors/bootstrap.bundle.min.js',
'/js/vendors/jquery.easing.min.js',
'/js/vendors/jquery.magnific-popup.min.js',
'/js/vendors/jquery.min.js',
'/js/vendors/owl.carousel.min.js',
'/js/vendors/swiper.min.js',
'/service-worker.js',
'/manifest.json',
]);
})
);
});
return response || fetchPromise;
});
}));
});
self.addEventListener('install', function (event) {
self.skipWaiting();
console.log("Latest version installed!");
});