-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsevice-worker.js
36 lines (34 loc) · 1.35 KB
/
sevice-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
const CACHE_NAME = 'quran-viewer-cache-v1';
const urlsToCache = [
'/',
'index.html',
'style/style.css',
'https://fonts.googleapis.com/css2?family=Amiri+Quran&display=swap',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css',
'https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/words/word.json',
'https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/words/nastaliq-quranwbw.json',
'https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/words/en-quranwbw.json',
'https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/words/ur-quranwbw.json',
'https://quran-online.pages.dev/source/download.png',
'https://kit.fontawesome.com/a076d05399.js'
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
console.log('Caching resources');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((cachedResponse) => {
if (cachedResponse) {
return cachedResponse;
}
return fetch(event.request);
})
);
});