mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +01:00
Remove all console.log, console.warn, and console.error statements that were added for debugging in article cache, service worker, and image caching code.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Development Service Worker - simplified version for testing image caching
|
|
// This is served in dev mode when vite-plugin-pwa doesn't serve the injectManifest SW
|
|
|
|
self.addEventListener('install', (event) => {
|
|
self.skipWaiting()
|
|
})
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(clients.claim())
|
|
})
|
|
|
|
// Image caching - simple version for dev testing
|
|
self.addEventListener('fetch', (event) => {
|
|
const url = new URL(event.request.url)
|
|
const isImage = event.request.destination === 'image' ||
|
|
/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(url.pathname)
|
|
|
|
if (isImage) {
|
|
event.respondWith(
|
|
caches.open('boris-images-dev').then((cache) => {
|
|
return cache.match(event.request).then((cachedResponse) => {
|
|
if (cachedResponse) {
|
|
return cachedResponse
|
|
}
|
|
|
|
return fetch(event.request).then((response) => {
|
|
if (response.ok) {
|
|
cache.put(event.request, response.clone())
|
|
}
|
|
return response
|
|
})
|
|
})
|
|
})
|
|
)
|
|
}
|
|
})
|
|
|