Skip to content

Commit

Permalink
chore: update workbox caching strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
WRXinYue committed Aug 20, 2024
1 parent 1dc2229 commit 0ee9501
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions theme/valaxy.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ export default defineTheme<ThemeConfig>((options) => {
},
workbox: {
runtimeCaching: [
{
urlPattern: ({ request }) => request.destination === 'document',
handler: 'NetworkFirst',
},
{
urlPattern: ({ request }) => request.destination === 'script' || request.destination === 'style',
handler: 'StaleWhileRevalidate',
handler: 'NetworkFirst',
options: {
cacheName: 'static-resources',
},
Expand All @@ -50,18 +54,18 @@ export default defineTheme<ThemeConfig>((options) => {
urlPattern: ({ request }) => request.destination === 'image',
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
cacheName: 'img-cache',
expiration: {
maxEntries: 10,
maxEntries: 1000,
maxAgeSeconds: 60 * 60 * 24 * 30,
},
},
},
{
urlPattern: /.*\.mp4$/,
urlPattern: ({ request }) => request.destination === 'video',
handler: 'CacheFirst',
options: {
cacheName: 'media',
cacheName: 'media-cache',
expiration: {
maxEntries: 500,
maxAgeSeconds: 60 * 60 * 24 * 365,
Expand Down

0 comments on commit 0ee9501

Please sign in to comment.