-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoriginal-sw.js
More file actions
33 lines (32 loc) · 806 Bytes
/
original-sw.js
File metadata and controls
33 lines (32 loc) · 806 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
27
28
29
30
31
32
33
/******
* Installing the service worker
* Caching everything of the project
* Returning the cached files
*/
self.addEventListener("install", (event) => {
console.log("Installed the app service worker!");
event.waitUntil(
caches.open("static").then((cache) => {
return cache.addAll([
".",
"./public/css/app.css",
"./public/js/app.js",
"./resources/views/index.php",
"./resources/views/includes/footer.php",
"./public/logo/logo.png"
]);
})
);
});
/*****
* Fetch the cached files
* Looking for a match with the request
* return the response
*/
self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});