π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
feat: enhance service worker caching strategies and increase maximum cache size
Smaug6739de3ff4b5f9d8
diff --git a/frontend/app/sw.ts b/frontend/app/sw.tsindex 1fa55153..16a0467c 100644--- a/frontend/app/sw.ts+++ b/frontend/app/sw.ts@@ -3,6 +3,8 @@ import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching';import { registerRoute, NavigationRoute } from 'workbox-routing';import { NetworkFirst } from 'workbox-strategies';import { clientsClaim } from 'workbox-core';+import { CacheableResponsePlugin } from 'workbox-cacheable-response';+import { ExpirationPlugin } from 'workbox-expiration';declare let self: ServiceWorkerGlobalScope;@@ -12,21 +14,30 @@ clientsClaim();// Precache all assets generated by the buildcleanupOutdatedCaches();-precacheAndRoute(self.__WB_MANIFEST);+precacheAndRoute(self.__WB_MANIFEST); // This will be replaced by the build process with the list of assets to precache// βββ Navigation (HTML pages) βββββββββββββββββββββββββββββββββββββββββββββββββregisterRoute(new NavigationRoute(- new NetworkFirst({ networkTimeoutSeconds: 3 }),+ new NetworkFirst({+ cacheName: 'pages-cache',+ networkTimeoutSeconds: 3,+ plugins: [+ new CacheableResponsePlugin({+ statuses: [0, 200],+ }),+ new ExpirationPlugin({+ maxEntries: 100,+ maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days+ }),+ ],+ }),{ denylist: [/^\/api\//] },),);// βββ API cache βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-registerRoute(- ({ url }) => url.pathname.startsWith('/api/') && !url.pathname.startsWith('/api/backup/'),- new NetworkFirst({ cacheName: 'api-cache' }),-);+registerRoute(({ url }) => url.pathname.startsWith('/api/') && !url.pathname.startsWith('/api/backup/'), new NetworkFirst({ cacheName: 'api-cache' }));// βββ Share Target API handler ββββββββββββββββββββββββββββββββββββββββββββββββ// When the PWA receives a share via the Share Target API (POST with form data),@@ -36,10 +47,7 @@ registerRoute(self.addEventListener('fetch', (event: FetchEvent) => {const url = new URL(event.request.url);- if (- url.pathname === '/dashboard/share-target' &&- event.request.method === 'POST'- ) {+ if (url.pathname === '/dashboard/share-target' && event.request.method === 'POST') {event.respondWith(handleShareTarget(event.request));}});diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.tsindex 492d5b31..8e59c9af 100644--- a/frontend/nuxt.config.ts+++ b/frontend/nuxt.config.ts@@ -155,7 +155,7 @@ export default defineNuxtConfig({filename: 'sw.ts',base: '/',injectManifest: {- maximumFileSizeToCacheInBytes: 3000000,+ maximumFileSizeToCacheInBytes: 30_000_000,globPatterns: ['**/*.{js,css,html,ico,png,svg}'],},},