From 55ce4f7c991e5c1913d22183928944f49f142702 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 14 Sep 2021 18:54:09 +0800 Subject: [PATCH] refactor: add plugin service worker cache --- web/webpack.config.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/webpack.config.ts b/web/webpack.config.ts index b5d135de..b8217bc3 100644 --- a/web/webpack.config.ts +++ b/web/webpack.config.ts @@ -142,6 +142,7 @@ const config: Configuration = { }) as any, new MiniCssExtractPlugin({ filename: 'styles-[contenthash].css' }), new WorkboxPlugin.GenerateSW({ + // https://developers.google.com/web/tools/workbox // these options encourage the ServiceWorkers to get in there fast // and not allow any straggling "old" SWs to hang around clientsClaim: true, @@ -169,6 +170,17 @@ const config: Configuration = { }, }, }, + { + // 匹配内置 plugins 以加速 + urlPattern: /plugins\/com\.msgbyte(.*?)\.js/, + handler: 'CacheFirst', + options: { + cacheName: 'builtin-plugins', + expiration: { + maxAgeSeconds: 1 * 60 * 60, // 1h + }, + }, + }, ], }), ],