AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(web): defer PDF runtime from PWA precache
tianma-if663f76eecacc
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex b773d00a..0da935e6 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -200,6 +200,10 @@ export default defineConfig({"**/vendor-mermaid-*.js","**/*Diagram-*.js","**/vendor-codemirror-*.js",+ // PDF.js is loaded only when a PDF preview or thumbnail is rendered.+ // Keep its runtime out of the install-time app-shell precache and cache+ // it after first use instead.+ "**/vendor~pdf-*.js",],navigateFallback: null,navigationPreload: true,@@ -245,6 +249,17 @@ export default defineConfig({},},},+ {+ urlPattern: ({ url }) => /\/assets\/(?:vendor~pdf-|pdf\.worker\.min-)/.test(url.pathname),+ handler: "CacheFirst",+ options: {+ cacheName: "edgeever-optional-pdf",+ expiration: {+ maxEntries: 4,+ maxAgeSeconds: 30 * 24 * 60 * 60,+ },+ },+ },{urlPattern: ({ url }) => url.pathname.startsWith("/api/") || url.pathname.startsWith("/mcp/"),handler: "NetworkOnly",diff --git a/scripts/verify-web-performance.mjs b/scripts/verify-web-performance.mjsindex 42f6dc74..cd442f7f 100644--- a/scripts/verify-web-performance.mjs+++ b/scripts/verify-web-performance.mjs@@ -9,6 +9,7 @@ const staticHeaders = readFileSync(join(distDirectory, "_headers"), "utf8");assert.match(serviceWorker, /edgeever-resource-blobs/, "PWA must provide a runtime cache for resource bytes");assert.match(serviceWorker, /CacheFirst/, "PWA resource bytes must use a cache-first runtime strategy");assert.match(serviceWorker, /edgeever-app-shell/, "PWA navigation must use a dedicated app-shell runtime cache");+assert.match(serviceWorker, /edgeever-optional-pdf/, "PWA must cache the optional PDF runtime after first use");assert.match(serviceWorker, /NetworkFirst/, "PWA navigation must prefer the current deployment over cached HTML");assert.match(serviceWorker, /PrecacheFallbackPlugin/, "PWA navigation must retain an offline app-shell fallback");assert.doesNotMatch(serviceWorker, /NavigationRoute/, "PWA navigation must not always serve the precached HTML shell");@@ -23,6 +24,7 @@ assert.doesNotMatch(precacheManifest, /\{url:"index\.html",/, "Current HTML mustassert.match(precacheManifest, /index\.html\?edgeever-offline-shell=/, "PWA must retain a versioned offline HTML shell");const optionalDiagramPattern = /(?:beautiful-mermaid|vendor-mermaid|mermaid\.core|vendor-codemirror|[^"']*Diagram-)[^"']*\.js/;assert.doesNotMatch(precacheManifest, optionalDiagramPattern, "Optional diagram chunks must remain out of the initial PWA precache");+assert.doesNotMatch(precacheManifest, /vendor~pdf-[^"']*\.js/, "Optional PDF.js runtime must remain out of the initial PWA precache");assert.doesNotMatch(precacheManifest, /noto-sans-sc-[^"']*\.woff2/, "Print-only Noto Sans SC shards must remain out of the PWA precache");const precacheURLs = [...precacheManifest.matchAll(/\{url:"([^"]+)"/g)].map((match) => match[1]);