fix: make sudoku comfortable as mobile web app
This commit is contained in:
1 parent
a26fdcc878
commit
f7b3213717
5 files changed
+35
-3
No files matched your search
@@ -0,0 +1,13 @@
|
||||
const CACHE = "sudoku-v1";
|
||||
const ASSETS = ["/sudoku", "/sudoku.webmanifest", "/favicon.png"];
|
||||
|
||||
self.addEventListener("install", event => event.waitUntil(caches.open(CACHE).then(cache => cache.addAll(ASSETS))));
|
||||
self.addEventListener("activate", event => event.waitUntil(self.clients.claim()));
|
||||
self.addEventListener("fetch", event => {
|
||||
if (event.request.method !== "GET" || new URL(event.request.url).origin !== self.location.origin) return;
|
||||
if (event.request.mode === "navigate") {
|
||||
event.respondWith(fetch(event.request).catch(() => caches.match("/sudoku")));
|
||||
return;
|
||||
}
|
||||
event.respondWith(caches.match(event.request).then(cached => cached || fetch(event.request)));
|
||||
});
|
||||
Reference in new issue
Block a user