Skip to content

Commit

Permalink
Update Cache Strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jason5ng32 committed Aug 7, 2024
1 parent 5dc9272 commit 364571c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ export default defineConfig({
'*.{js,css,html,png,svg,jpg,webp}',
],
runtimeCaching: [
{
urlPattern: /\/(sw\.js|registerSW\.js|manifest\.webmanifest)$/, // sw 文件
handler: 'NetworkFirst',
options: {
cacheName: 'critical-assets',
expiration: {
maxEntries: 3,
maxAgeSeconds: 4 * 60 * 60, // 4 小时
},
},
},
{
urlPattern: /\.(?:png|jpg|jpeg|svg|webp|woff|woff2)$/, // 图片文件
handler: 'CacheFirst',
Expand Down

0 comments on commit 364571c

Please sign in to comment.