Update service-worker.js
This commit is contained in:
+9
-4
@@ -1,4 +1,4 @@
|
|||||||
const CURRENT_VERSION = 'v70';
|
const CURRENT_VERSION = 'v72';
|
||||||
const CACHE_NAME = `cache-${CURRENT_VERSION}`;
|
const CACHE_NAME = `cache-${CURRENT_VERSION}`;
|
||||||
|
|
||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
@@ -64,9 +64,14 @@ self.addEventListener('activate', event => {
|
|||||||
caches.keys().then(cacheNames => {
|
caches.keys().then(cacheNames => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
cacheNames.map(cacheName => {
|
cacheNames.map(cacheName => {
|
||||||
if (cacheName.startsWith('cache-') && cacheName !== CACHE_NAME) {
|
if (cacheName.startsWith('cache-')) {
|
||||||
console.log(`Deleting old cache: ${cacheName}`);
|
const cacheVersion = parseInt(cacheName.replace('cache-', ''), 10);
|
||||||
return caches.delete(cacheName);
|
|
||||||
|
// Eğer mevcut cache versiyonu, CURRENT_VERSION'dan küçükse, sil
|
||||||
|
if (cacheVersion < parseInt(CURRENT_VERSION.replace('v', ''), 10)) {
|
||||||
|
console.log(`Deleting old cache: ${cacheName}`);
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user