From 6ce2231e70e69500d7bfc135e30aa128becde908 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 13 Feb 2021 19:53:40 +0900 Subject: [PATCH] =?UTF-8?q?ServiceWorker:=20onfetch=E3=81=A7=E4=BD=95?= =?UTF-8?q?=E3=82=82=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#7195)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Resolve #7192 * skip waiting * fix * refactor --- src/client/sw/sw.ts | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/client/sw/sw.ts b/src/client/sw/sw.ts index c93fe4926d..ec4de17551 100644 --- a/src/client/sw/sw.ts +++ b/src/client/sw/sw.ts @@ -10,7 +10,6 @@ import { I18n } from '../../misc/i18n'; //#region Variables const version = _VERSION_; const cacheName = `mk-cache-${version}`; -const apiUrl = `${location.origin}/api/`; let lang: string; let i18n: I18n; @@ -27,15 +26,7 @@ get('lang').then(async prelang => { //#region Lifecycle: Install self.addEventListener('install', ev => { - ev.waitUntil( - caches.open(cacheName) - .then(cache => { - return cache.addAll([ - `/?v=${version}` - ]); - }) - .then(() => self.skipWaiting()) - ); + self.skipWaiting(); }); //#endregion @@ -53,19 +44,9 @@ self.addEventListener('activate', ev => { }); //#endregion -// TODO: 消せるかも ref. https://github.com/syuilo/misskey/pull/7108#issuecomment-774573666 //#region When: Fetching self.addEventListener('fetch', ev => { - if (ev.request.method !== 'GET' || ev.request.url.startsWith(apiUrl)) return; - ev.respondWith( - caches.match(ev.request) - .then(response => { - return response || fetch(ev.request); - }) - .catch(() => { - return caches.match(`/?v=${version}`); - }) - ); + // Nothing to do }); //#endregion