1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-04 19:14:41 +00:00
Files
uwuzu-mirror/sw.js
T
2025-01-12 20:01:08 +09:00

49 lines
1.5 KiB
JavaScript

var CACHE_NAME = "app_uwuzu";
var urlsToCache = [
"/home/index.php",
"/unsupported.php",
];
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
return cache.addAll(urlsToCache);
}).catch(function(error) {
console.error("Failed to cache:", error);
})
);
});
/*
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
if (response) {
return response;
}
var url = new URL(event.request.url);
if (!url.pathname.includes(".")) {
if (!url.pathname.endsWith('/')) {
url.pathname += '/';
}
return caches.match(url.pathname + "index.php");
}
return fetch(event.request)
.then(function(networkResponse) {
return caches.open("app_uwuzu").then(function(cache) {
cache.put(event.request, networkResponse.clone());
return networkResponse;
});
})
.catch(function() {
return caches.match('/unsupported.php');
});
})
);
});
*/