Spaces:
Sleeping
Sleeping
Update static/service-worker.js
Browse files- static/service-worker.js +8 -49
static/service-worker.js
CHANGED
|
@@ -1,52 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
//
|
| 3 |
-
|
| 4 |
-
'
|
| 5 |
-
|
| 6 |
-
];
|
| 7 |
-
|
| 8 |
-
// Install event: opens a cache and adds the app shell files to it.
|
| 9 |
-
self.addEventListener('install', event => {
|
| 10 |
-
console.log('Service Worker: Installing...');
|
| 11 |
-
event.waitUntil(
|
| 12 |
-
caches.open(CACHE_NAME)
|
| 13 |
-
.then(cache => {
|
| 14 |
-
console.log('Service Worker: Caching app shell');
|
| 15 |
-
return cache.addAll(urlsToCache);
|
| 16 |
-
})
|
| 17 |
-
.then(() => self.skipWaiting())
|
| 18 |
-
);
|
| 19 |
-
});
|
| 20 |
-
|
| 21 |
-
// Activate event: removes old caches.
|
| 22 |
-
self.addEventListener('activate', event => {
|
| 23 |
-
console.log('Service Worker: Activating...');
|
| 24 |
-
event.waitUntil(
|
| 25 |
-
caches.keys().then(cacheNames => {
|
| 26 |
-
return Promise.all(
|
| 27 |
-
cacheNames.map(cache => {
|
| 28 |
-
if (cache !== CACHE_NAME) {
|
| 29 |
-
console.log('Service Worker: Clearing old cache');
|
| 30 |
-
return caches.delete(cache);
|
| 31 |
-
}
|
| 32 |
-
})
|
| 33 |
-
);
|
| 34 |
-
})
|
| 35 |
-
);
|
| 36 |
});
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
event.respondWith(
|
| 41 |
-
caches.match(event.request)
|
| 42 |
-
.then(response => {
|
| 43 |
-
// Cache hit - return response
|
| 44 |
-
if (response) {
|
| 45 |
-
return response;
|
| 46 |
-
}
|
| 47 |
-
// Not in cache - fetch from network
|
| 48 |
-
return fetch(event.request);
|
| 49 |
-
}
|
| 50 |
-
)
|
| 51 |
-
);
|
| 52 |
});
|
|
|
|
| 1 |
+
// यह एक बहुत ही बुनियादी सर्विस वर्कर है।
|
| 2 |
+
// इसका मुख्य काम ऐप को इंस्टॉल करने योग्य बनाना है।
|
| 3 |
+
self.addEventListener('install', (event) => {
|
| 4 |
+
console.log('Service worker installing...');
|
| 5 |
+
// आप भविष्य में यहां फाइलें कैश कर सकते हैं ताकि ऐप ऑफलाइन चले।
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
});
|
| 7 |
|
| 8 |
+
self.addEventListener('fetch', (event) => {
|
| 9 |
+
// अभी के लिए, हम बस नेटवर्क से अनुरोध प्राप्त करेंगे।
|
| 10 |
+
event.respondWith(fetch(event.request));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
});
|