26 lines
663 B
JavaScript
26 lines
663 B
JavaScript
const CACHE_NAME = 'pulse-v1';
|
|
const ASSETS = [
|
|
'/',
|
|
'/index.php',
|
|
'/assets/css/custom.css',
|
|
'/assets/js/main.js',
|
|
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css',
|
|
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js',
|
|
'https://cdn.jsdelivr.net/npm/chart.js'
|
|
];
|
|
|
|
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);
|
|
})
|
|
);
|
|
}); |