| Server IP : 188.114.97.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/ |
Upload File : |
const CACHE = 'polana-static-v350';
const PRECACHE = [
'/assets/img/pwa/icon-192.png',
'/assets/img/pwa/icon-512.png',
'/assets/img/favicon.png',
'/manifest.webmanifest',
'/admin/manifest.webmanifest',
'/tipy/manifest.webmanifest'
];
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(PRECACHE)).then(() => self.skipWaiting()));
});
self.addEventListener('activate', (event) => {
event.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key)))).then(() => self.clients.claim()));
});
self.addEventListener('fetch', (event) => {
const request = event.request;
if (request.method !== 'GET') return;
const url = new URL(request.url);
if (url.origin !== self.location.origin) return;
const isCode = url.pathname.startsWith('/assets/css/') || url.pathname.startsWith('/assets/js/');
const isStatic = url.pathname.startsWith('/assets/') || url.pathname.endsWith('.webmanifest');
if (!isStatic) return;
if (isCode) {
event.respondWith(fetch(request).then((response) => {
if (response && response.ok) caches.open(CACHE).then((cache) => cache.put(request, response.clone()));
return response;
}).catch(() => caches.match(request)));
return;
}
event.respondWith(caches.match(request).then((cached) => cached || fetch(request).then((response) => {
if (response && response.ok) caches.open(CACHE).then((cache) => cache.put(request, response.clone()));
return response;
})));
});