Create service-worker.js
Browse files- service-worker.js +32 -0
service-worker.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const cacheName = 'chatbot-cache-v1';
|
| 2 |
+
const assetsToCache = [
|
| 3 |
+
'/',
|
| 4 |
+
'/index.html',
|
| 5 |
+
'/styles.css',
|
| 6 |
+
'/script.js',
|
| 7 |
+
'/icon_vera.png',
|
| 8 |
+
'/icon_vera2.png',
|
| 9 |
+
'/manifest.json',
|
| 10 |
+
'/login.html',
|
| 11 |
+
'/login.png',
|
| 12 |
+
'/mic.png',
|
| 13 |
+
'/newchat.png',
|
| 14 |
+
'/register.html'
|
| 15 |
+
'/styles1.css'
|
| 16 |
+
];
|
| 17 |
+
|
| 18 |
+
self.addEventListener('install', event => {
|
| 19 |
+
event.waitUntil(
|
| 20 |
+
caches.open(cacheName).then(cache => {
|
| 21 |
+
return cache.addAll(assetsToCache);
|
| 22 |
+
})
|
| 23 |
+
);
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
self.addEventListener('fetch', event => {
|
| 27 |
+
event.respondWith(
|
| 28 |
+
caches.match(event.request).then(response => {
|
| 29 |
+
return response || fetch(event.request);
|
| 30 |
+
})
|
| 31 |
+
);
|
| 32 |
+
});
|