-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice-worker.js
30 lines (29 loc) · 976 Bytes
/
service-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
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('my-cache')
.then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/css/index.css',
'/img/TurkceWordle_256.png',
'/img/settings.png'
]);
})
);
self.skipWaiting();
});
self.addEventListener('fetch', function(event) {
// Check if the request is for the file you want to always fetch from the network
if (event.request.url.includes('i18n') || event.request.url.includes('dictionaries')) {
// Fetch the file from the network
event.respondWith(fetch(event.request));
} else {
// For other files, serve them from the cache
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
}
});