From 312f46378dc6458c6ecf9aed9714b96c8a78daef Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 15 Mar 2022 22:30:15 +0900 Subject: [PATCH] =?UTF-8?q?URL=E3=82=92sw.js=E3=81=AB=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/web/index.ts | 3 ++- packages/client/src/scripts/initialize-sw.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 26ab31a85c..f57c4bb826 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -101,9 +101,10 @@ router.get('/twemoji/(.*)', async ctx => { }); // ServiceWorker -router.get(`/sw.${config.version}.js`, async ctx => { +router.get(`/sw.js`, async ctx => { await send(ctx as any, `/sw.js`, { root: swAssets, + maxage: ms('10 minutes'), }); }); diff --git a/packages/client/src/scripts/initialize-sw.ts b/packages/client/src/scripts/initialize-sw.ts index d90196360e..7bacfbdf00 100644 --- a/packages/client/src/scripts/initialize-sw.ts +++ b/packages/client/src/scripts/initialize-sw.ts @@ -1,12 +1,12 @@ import { instance } from '@/instance'; import { $i } from '@/account'; import { api } from '@/os'; -import { lang, version } from '@/config'; +import { lang } from '@/config'; export async function initializeSw() { if (!('serviceWorker' in navigator)) return; - navigator.serviceWorker.register(`/sw.${version}.js`, { scope: '/', type: 'classic' }); + navigator.serviceWorker.register(`/sw.js`, { scope: '/', type: 'classic' }); navigator.serviceWorker.ready.then(registration => { registration.active?.postMessage({ msg: 'initialize',