NotionRaymond XuExplainer
How we made Notion available offline
Summary
Notion's Offline Mode required turning a best-effort SQLite cache into storage that could guarantee a page and all its dependent records were available without a network connection. The system uses a forest of offline page trees backed by offline_page and offline_action tables, allowing independent reasons such as explicit toggles, favorites, automatic downloads, and inheritance to coexist while preserving hierarchy. To keep content current, clients subscribe to push channels emitted by the page version snapshot system, then use lastDownloadedTimestamp and server lastUpdatedTime to fetch only newer pages after reconnecting. When pages or databases change, the client reconciles fresh page and database snapshots with offline_action, adding or removing rows rather than rebuilding entire trees. This makes offline availability precise and eventually consistent, while supporting conflict resolution through the CRDT data model.
Context
Offline Mode needed stronger guarantees than Notion's best-effort SQLite cache: every page used without a network connection had to include all required records and remain up to date. The system also had to handle multiple availability reasons, inherited offline access, changing page and database hierarchies, and conflict resolution.
Approach / What changed
Notion evolved its SQLite cache into a persistent storage layer using offline_page and offline_action tables to model offline page trees and their availability reasons. Push-based page updates, timestamp comparisons on reconnect, and incremental reconciliation of offline_action with fresh page and database snapshots keep offline content current without unnecessary refetches or full tree rebuilds.
Takeaways
offline_action records each independent reason a page is available offline, so removing one reason does not remove access while another reason remains.
Clients subscribe to per-page update channels and compare lastDownloadedTimestamp with the server's lastUpdatedTime to fetch only pages that changed while offline.
Fresh page and database snapshots are reconciled with offline_action by adding inherited descendants and removing entries for deleted databases or out-of-view rows.
Source and freshness
- Source
- notion.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.