Offline Mode and Caching Strategy
Ultra PDF Editor is built to operate offline. Astro ships static content, while the React editor island and pdf.js/pdflib bundles can be cached via the service worker.
Caching tiers
- App shell: HTML, CSS, fonts, and small JS bundles precache during the service worker install event.
- Editor chunk: The heavy editor bundle (pdf.js worker + pdf-lib) uses a stale-while-revalidate strategy so repeat visits load instantly while updates stream in behind the scenes.1
- User PDFs: Files never persist automatically. Offer the optional “remember recent files” toggle (planned) to store encrypted blobs in IndexedDB.
Recommended service worker setup
- Cache static assets with
CacheFirstto deliver near-instant responses. - Use
NetworkFirstfor documentation pages so content updates propagate quickly. - Serve the
/editor/route offline by precaching the editor chunk and providing an offline fallback message prompting users to open a local file.
Testing offline behavior
- Run
npm run dev. - Open the app in Chrome, start Lighthouse from DevTools, and enable the Service Worker audit.
- Toggle Offline in the Network panel to confirm the editor still boots and previously loaded docs render from cache.
Handling updates
- Bump the service worker version whenever you modify cached assets.
- Broadcast a
refreshnotification (coming soon) so users can reload without losing state when updates are available.
Footnotes
-
Google Chrome team, The Offline Cookbook, web.dev/articles/offline-cookbook. ↩