Update service-worker.js
This commit is contained in:
+73
-12
@@ -1,15 +1,76 @@
|
|||||||
|
const CACHE_NAME = 'site-cache-v1';
|
||||||
|
const versionMap = {}; // Versiyonların yönetimi
|
||||||
|
|
||||||
|
// İstenilen dosyalar burada belirtilecek
|
||||||
|
const urlsToCache = [
|
||||||
|
'/',
|
||||||
|
'/index.html',
|
||||||
|
'/home_en.html',
|
||||||
|
'/home_tr.html',
|
||||||
|
'/404.html',
|
||||||
|
'/CSS/unpkg.comswiper@8swiper-bundle.min.css',
|
||||||
|
'/FONTS/Inconsolata.woff2',
|
||||||
|
'/FONTS/Jaro.woff2',
|
||||||
|
'/FONTS/Monomakh.woff2',
|
||||||
|
'/FONTS/Montserrat.woff2',
|
||||||
|
'/FONTS/TacOne.woff2',
|
||||||
|
'/FONTS/Teko.woff2',
|
||||||
|
'/JAVASCRIPT/1.js',
|
||||||
|
'/JAVASCRIPT/tr/1.js',
|
||||||
|
'/JAVASCRIPT/darkmode-js.min.js',
|
||||||
|
'/JAVASCRIPT/gsap.min.js',
|
||||||
|
'/JAVASCRIPT/swiper-bundle.min.js',
|
||||||
|
'/img/profile_photo1.webp',
|
||||||
|
'/img/character1.webp',
|
||||||
|
'/img/character2.webp',
|
||||||
|
'/img/character3.webp',
|
||||||
|
'/img/ai.webp',
|
||||||
|
'/img/app.webp',
|
||||||
|
'/img/cyber.webp',
|
||||||
|
'/img/game.webp',
|
||||||
|
'/img/robotic.webp',
|
||||||
|
'/img/web.webp',
|
||||||
|
'/img/up.webp',
|
||||||
|
'/img/icon.ico',
|
||||||
|
'/sitemap.xml',
|
||||||
|
'/manifest.json',
|
||||||
|
'/robots.txt',
|
||||||
|
'/.htaccess.txt'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Install event: Cache the specified URLs
|
||||||
|
self.addEventListener('install', (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME).then((cache) => {
|
||||||
|
return cache.addAll(urlsToCache);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetch event: Serve cached files first, then fetch from network
|
||||||
|
self.addEventListener('fetch', (event) => {
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(event.request).then((cachedResponse) => {
|
||||||
|
if (cachedResponse) {
|
||||||
|
return cachedResponse;
|
||||||
|
}
|
||||||
|
return fetch(event.request);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activate event: Cleanup old caches
|
||||||
|
self.addEventListener('activate', (event) => {
|
||||||
|
const cacheWhitelist = [CACHE_NAME];
|
||||||
|
event.waitUntil(
|
||||||
caches.keys().then((cacheNames) => {
|
caches.keys().then((cacheNames) => {
|
||||||
cacheNames.forEach((cacheName) => {
|
return Promise.all(
|
||||||
caches.open(cacheName).then(async (cache) => {
|
cacheNames.map((cacheName) => {
|
||||||
const requests = await cache.keys();
|
if (!cacheWhitelist.includes(cacheName)) {
|
||||||
for (let request of requests) {
|
return caches.delete(cacheName);
|
||||||
if (request.url.startsWith(location.origin)) {
|
|
||||||
const deleted = await cache.delete(request);
|
|
||||||
if (deleted) {
|
|
||||||
console.log(`🗑️ Silindi: ${request.url}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user