-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceWorker.js
68 lines (64 loc) · 2.09 KB
/
serviceWorker.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
63
64
65
66
67
68
const staticAnimeshData = "site-cache-v1";
const assets = [
// "/",
"index.html",
"assets/css/styles.css",
"assets/css/swiper-bundle.min.css",
"assets/css/animate.min.css",
"assets/js/main.js",
"assets/js/swiper-bundle.min.js",
"assets/js/svg-inject.min.js",
"assets/js/smtp.js",
"assets/pdf/emmanpbarrameda_resume.pdf",
"assets/img/about-me.png",
"assets/img/about-me2.png",
"assets/img/blob.svg",
"assets/img/code-svg.svg",
"assets/img/emmanpbarrameda-logo-1x1-white_transparent_svg.svg",
"assets/img/emmanpbarrameda-logo-1x1-white_transparent.png",
"assets/img/emmanpbarrameda-logo-white_transparent.png",
"assets/img/profile.png",
"assets/img/skills/android.svg",
"assets/img/skills/c.svg",
"assets/img/skills/c++.svg",
"assets/img/skills/css.svg",
"assets/img/skills/git.svg",
"assets/img/skills/github.svg",
"assets/img/skills/html.svg",
"assets/img/skills/java.svg",
"assets/img/skills/javascript.svg",
"assets/img/skills/php.svg",
"assets/img/skills/laravel.svg",
"assets/img/skills/bootstrap.svg",
"assets/img/skills/mysql.svg",
"assets/img/skills/photoshop.svg",
"assets/img/skills/vb.net.svg",
"assets/img/certs/cert-best-in-ict.jpeg",
"assets/img/certs/cert-best-thesis.jpeg",
"assets/img/certs/cert-with-honor-shs.jpeg",
"assets/img/certs/cert-tech-together.jpg",
"assets/img/certs_courses/c.jpg",
"assets/img/certs_courses/cpp.jpg",
"assets/img/certs_courses/html.jpg",
"assets/img/certs_courses/java.jpg",
];
self.addEventListener("install", (installEvent) => {
installEvent.waitUntil(
caches.open(staticAnimeshData).then((cache) => {
return cache.addAll(assets).catch((error) => {
console.error("Failed to cache assets:", error);
const failedAssets = assets.filter((asset) =>
error.message.includes(asset)
);
console.log("Failed to cache these assets:", failedAssets);
});
})
);
});
self.addEventListener("fetch", (fetchEvent) => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then((res) => {
return res || fetch(fetchEvent.request);
})
);
});