From ed6e4dce685fd54c07143c364b07d708e9483943 Mon Sep 17 00:00:00 2001 From: Nofated095 Date: Thu, 30 Nov 2023 18:07:28 +0800 Subject: [PATCH] update sw.js --- scripts/service-worker-injector.js | 2 +- source/sw.js | 40 +++--------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/scripts/service-worker-injector.js b/scripts/service-worker-injector.js index e753dcf..2fea6be 100644 --- a/scripts/service-worker-injector.js +++ b/scripts/service-worker-injector.js @@ -1,3 +1,3 @@ -hexo.extend.injector.register('body_end', '', 'default'); +hexo.extend.injector.register('body_end', '', 'default'); hexo.extend.injector.register('body_end', '', 'default'); diff --git a/source/sw.js b/source/sw.js index da530aa..b0f4bd7 100644 --- a/source/sw.js +++ b/source/sw.js @@ -9,7 +9,7 @@ const { CacheFirst, NetworkFirst, NetworkOnly, StaleWhileRevalidate } = strategi const { ExpirationPlugin } = expiration; const { CacheableResponsePlugin } = cacheableResponse; -const cacheSuffixVersion = '-231126a', +const cacheSuffixVersion = '-231130a', // precacheCacheName = core.cacheNames.precache, // runtimeCacheName = core.cacheNames.runtime, maxEntries = 100; @@ -36,23 +36,6 @@ core.skipWaiting(); core.clientsClaim(); precaching.cleanupOutdatedCaches(); -routing.registerRoute( - /.*lf3-cdn-tos\.bytecdntp\.com/, - new CacheFirst({ - cacheName: 'static-immutable' + cacheSuffixVersion, - fetchOptions: { - mode: 'cors', - credentials: 'omit' - }, - plugins: [ - new ExpirationPlugin({ - maxAgeSeconds: 30 * 24 * 60 * 60, - purgeOnQuotaError: true - }) - ] - }) -); - routing.registerRoute( /.*xgjalbum\.oss-cn-hangzhou\.aliyuncs\.com/, new CacheFirst({ @@ -104,23 +87,6 @@ routing.registerRoute( }) ); -routing.registerRoute( - /.*comment\.9595095\.xyz/, - new CacheFirst({ - cacheName: 'static-immutable' + cacheSuffixVersion, - fetchOptions: { - mode: 'cors', - credentials: 'omit' - }, - plugins: [ - new ExpirationPlugin({ - maxAgeSeconds: 30 * 24 * 60 * 60, - purgeOnQuotaError: true - }) - ] - }) -); - routing.registerRoute( /.*cdn\.jsdelivr\.net/, new CacheFirst({ @@ -233,8 +199,8 @@ routing.registerRoute( ); routing.registerRoute( - // Cache CSS files - /.*\.(json)/, + // Cache fonts files + /.*\.(woff2|woff)/, // Use cache but update in the background ASAP StaleWhileRevalidateInstance );