차량 모니터 서비스워커 인증 캐시 제외

This commit is contained in:
seo
2026-07-12 10:04:46 +09:00
parent 8c14d55d4d
commit c2305b8ad3
3 changed files with 12 additions and 4 deletions
+7 -3
View File
@@ -1,6 +1,5 @@
const CACHE_NAME = 'car-monitor-v1';
const CACHE_NAME = 'car-monitor-v2';
const CORE_ASSETS = [
'/car/monitor.php',
'/car/assets/favicon.svg',
'/car/assets/icon-192.png',
'/car/assets/icon-512.png',
@@ -29,13 +28,18 @@ self.addEventListener('activate', event => {
self.addEventListener('fetch', event => {
const url = new URL(event.request.url);
if (url.origin !== location.origin || url.searchParams.get('mode') === 'ajax') {
if (url.origin !== location.origin) {
return;
}
if (event.request.mode === 'navigate' || url.pathname.endsWith('.php') || url.searchParams.has('mode')) {
return;
}
event.respondWith(
fetch(event.request)
.then(response => {
if (!response || !response.ok) return response;
const copy = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, copy));
return response;