From 1d079c37561c7f1c2ef9aa02ed7ffa73d48cbe73 Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:39:48 +0300 Subject: [PATCH] Update service-worker.js --- service-worker.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/service-worker.js b/service-worker.js index 2943fea..d7c46cf 100644 --- a/service-worker.js +++ b/service-worker.js @@ -1,4 +1,4 @@ -const CURRENT_VERSION = 'v37'; +const CURRENT_VERSION = 'v38'; const CACHE_NAME = `cache-${CURRENT_VERSION}`; const urlsToCache = [ @@ -38,15 +38,15 @@ const urlsToCache = [ '/.htaccess.txt' ]; -// Install event - cache files +// Install event - cache files and force activation self.addEventListener('install', event => { event.waitUntil( - caches.open(CACHE_NAME) - .then(cache => { - console.log(`Caching files for version: ${CURRENT_VERSION}`); - return cache.addAll(urlsToCache); - }) + caches.open(CACHE_NAME).then(cache => { + console.log(`Caching files for version: ${CURRENT_VERSION}`); + return cache.addAll(urlsToCache); + }) ); + self.skipWaiting(); // Anında yeni versiyonu yükle }); // Fetch event - serve from cache if available, else fetch from network @@ -58,7 +58,7 @@ self.addEventListener('fetch', event => { ); }); -// Activate event - delete old caches if version is different +// Activate event - delete old caches and update clients self.addEventListener('activate', event => { event.waitUntil( caches.keys().then(cacheNames => { @@ -73,6 +73,10 @@ self.addEventListener('activate', event => { }).then(() => { console.log(`Cache updated to version: ${CURRENT_VERSION}`); return self.clients.claim(); + }).then(() => { + self.clients.matchAll().then(clients => { + clients.forEach(client => client.navigate(client.url)); // Tüm sayfaları yenile + }); }) ); });