26 lines
572 B
JavaScript
26 lines
572 B
JavaScript
const CACHE_NAME = 'agency-cache-v1';
|
|
const ASSETS = [
|
|
'/',
|
|
'/index.html',
|
|
'/src/main.js',
|
|
'/src/style.css',
|
|
'/manifest.json',
|
|
'/icon-192.png',
|
|
'/icon-512.png'
|
|
];
|
|
|
|
self.addEventListener('install', (event) => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => {
|
|
return cache.addAll(ASSETS);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
event.respondWith(
|
|
caches.match(event.request).then((response) => {
|
|
return response || fetch(event.request);
|
|
})
|
|
);
|
|
});
|