Skip to content

Commit b1a4c96

Browse files
committed
Added Offline reading support page.
Signed-off-by: Someshdiwan <[email protected]>
1 parent 3693032 commit b1a4c96

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

site/assets/sw.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
const cacheName = 'java-evolution-cache-v1';
2+
const assetsToCache = [
3+
'/',
4+
'/JavaEvolution-Learning-Growing-Mastering/index.html',
5+
'/JavaEvolution-Learning-Growing-Mastering/assets/style.css',
6+
'/JavaEvolution-Learning-Growing-Mastering/assets/script.js',
7+
// Add more files as needed
8+
];
9+
10+
self.addEventListener("install", (event) => {
11+
event.waitUntil(
12+
caches.open(cacheName).then((cache) => cache.addAll(assetsToCache))
13+
);
14+
});
15+
16+
self.addEventListener("fetch", (event) => {
17+
event.respondWith(
18+
caches.match(event.request).then((response) => response || fetch(event.request))
19+
);
20+
});
21+
22+
23+
/*
124
self.addEventListener("install", function (e) {
225
console.log("Service Worker Installed");
326
});
427
528
self.addEventListener("fetch", function (e) {
629
// Just let requests pass through for now
7-
});
30+
});*/

0 commit comments

Comments
 (0)