-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
26 lines (24 loc) · 721 Bytes
/
sw.js
File metadata and controls
26 lines (24 loc) · 721 Bytes
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
const cacheName = 'intranet'
// Cache all the files to make a PWA
self.addEventListener('install', e => {
e.waitUntil(
caches.open(cacheName).then(cache => {
// Our application only has two files here index.html and manifest.json
// but you can add more such as style.css as your app grows
return cache.addAll([
'./index.php',
'./manifest.json',
])
}),
)
})
// Our service worker will intercept all fetch requests
// and check if we have cached the file
// if so it will serve the cached file
self.addEventListener('fetch', function (event) {
event.respondWith(
fetch(event.request).then(function (networkResponse) {
return networkResponse
}),
)
})