| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web31/web/slots/ |
Upload File : |
/* Reel Royale – Service Worker
* Macht die App installierbar (PWA) und beschleunigt statische Assets.
* Strategie:
* - Navigationen (HTML): Network-first, Fallback auf offline.html (keine privaten Seiten cachen).
* - Statische Assets (css/js/png/svg/woff …): Stale-while-revalidate.
* - API / POST / dynamische PHP-Endpunkte: nie cachen (immer Netzwerk).
*/
const VERSION = 'rr-v1';
const STATIC_CACHE = 'rr-static-' + VERSION;
const PRECACHE = [
'./offline.html',
'./manifest.php',
'./css/core.css',
'./css/themes.css',
'./css/animations.css',
'./css/roulette.css',
'./js/main.js',
'./js/util.js',
'./assets/img/icons/icon-192.png',
'./assets/img/icons/icon-512.png',
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(STATIC_CACHE)
.then((cache) => cache.addAll(PRECACHE).catch(() => null))
.then(() => self.skipWaiting())
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys()
.then((keys) => Promise.all(keys.filter((k) => k !== STATIC_CACHE).map((k) => caches.delete(k))))
.then(() => self.clients.claim())
);
});
function isStaticAsset(url) {
return /\.(?:css|js|mjs|png|jpg|jpeg|gif|webp|svg|ico|woff2?|ttf|otf|mp3|ogg|wav)$/i.test(url.pathname);
}
self.addEventListener('fetch', (event) => {
const req = event.request;
if (req.method !== 'GET') return; // POST (Spins/Login) immer durchreichen
const url = new URL(req.url);
if (url.origin !== self.location.origin) return; // fremde Origin (Fonts/CDN) unverändert
// API / PHP-Endpunkte mit Query nie cachen → frische Daten
if (url.pathname.indexOf('/api/') !== -1) return;
// Navigationen: Network-first, Offline-Fallback
if (req.mode === 'navigate') {
event.respondWith(
fetch(req).catch(() => caches.match('./offline.html', { ignoreSearch: true }))
);
return;
}
// Statische Assets: Stale-while-revalidate
if (isStaticAsset(url)) {
event.respondWith(
caches.open(STATIC_CACHE).then((cache) =>
cache.match(req).then((cached) => {
const network = fetch(req)
.then((res) => { if (res && res.status === 200) cache.put(req, res.clone()); return res; })
.catch(() => cached);
return cached || network;
})
)
);
}
});