forked from mirror/crumbs-original
fix: enable offline page caching in service worker for PWA refresh support
Navigation requests had no caching rule, so refreshing offline showed the browser's default "you are offline" page. Add NetworkFirst runtime caching for navigations (3s timeout), cache Google Fonts for offline use, remove conflicting static webmanifest in favor of the plugin-generated one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
8475ec807e
commit
0965da70b4
+18
-1
@@ -40,8 +40,17 @@ export default defineConfig({
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,woff,woff2}'],
|
||||
navigateFallback: '/',
|
||||
navigateFallback: null,
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ request }) => request.mode === 'navigate',
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'pages-cache',
|
||||
networkTimeoutSeconds: 3,
|
||||
expiration: { maxEntries: 50, maxAgeSeconds: 30 * 24 * 60 * 60 }
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: /\/api\/notes\/.*\/attachments\?attachmentId=/,
|
||||
handler: 'CacheFirst',
|
||||
@@ -57,6 +66,14 @@ export default defineConfig({
|
||||
cacheName: 'api-cache',
|
||||
expiration: { maxEntries: 50, maxAgeSeconds: 300 }
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: /^https?:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/,
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'google-fonts-cache',
|
||||
expiration: { maxEntries: 10, maxAgeSeconds: 365 * 24 * 60 * 60 }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user