キャッシュ対策

This commit is contained in:
tamaina 2021-12-23 21:17:12 +09:00
parent 4101d156f3
commit 469434dd9a
2 changed files with 3 additions and 3 deletions

View File

@ -99,7 +99,7 @@ router.get('/twemoji/(.*)', async ctx => {
});
// ServiceWorker
router.get('/sw.js', async ctx => {
router.get(`/sw.${config.version}.js`, async ctx => {
await send(ctx as any, `/sw.js`, {
root: swAssets,
});

View File

@ -1,14 +1,14 @@
import { instance } from '@/instance';
import { $i } from '@/account';
import { api } from '@/os';
import { lang } from '@/config';
import { lang, version } from '@/config';
export async function initializeSw() {
if (instance.swPublickey &&
('serviceWorker' in navigator) &&
('PushManager' in window) &&
$i && $i.token) {
navigator.serviceWorker.register(`/sw.js`, { scope: '/', type: 'classic' });
navigator.serviceWorker.register(`/sw.${version}.js`, { scope: '/', type: 'classic' });
navigator.serviceWorker.ready.then(registration => {
registration.active?.postMessage({