Overview
The article discusses the implementation of Offline Mode in Notion, a feature that allows users to create, edit, and view pages without an internet connection. It details the architectural changes made to the storage layer, tracking of offline pages, and methods for keeping content up-to-date, addressing challenges such as conflict resolution and data synchronization.
What You'll Learn
1
How to implement a persistent storage layer for offline access
2
Why tracking offline page availability is crucial for user experience
3
How to use push-based updates for syncing offline content
4
When to apply conflict resolution strategies in offline mode
Prerequisites & Requirements
- Understanding of caching and data synchronization concepts
- Familiarity with SQLite and CRDT data models(optional)
Key Questions Answered
What challenges did Notion face when implementing Offline Mode?
Notion faced challenges related to reference tracking, background syncing, and rich-text conflict resolution due to its unique block architecture. Ensuring that pages were fully usable offline required a robust storage layer and effective tracking of which pages were available without an internet connection.
How does Notion keep offline pages updated with server changes?
Notion uses a push-based update system where clients subscribe to channels for each offline page. When updates are made, the server emits messages that prompt clients to fetch the latest changes, ensuring offline pages remain current without unnecessary polling.
What is the purpose of the offline_action table in Notion's architecture?
The offline_action table tracks the reasons why each page or database is available offline. This allows Notion to maintain a consistent offline experience by ensuring pages are only removed from offline access when all reasons for their availability are gone.
How does Notion handle offline inheritance for pages?
Notion implements offline inheritance by automatically downloading pages that are part of a database marked as available offline. This ensures that up to 50 pages in the current view are also accessible offline, even if they weren't explicitly toggled for offline access.
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Implement a robust tracking system for offline pages to enhance user experience.By ensuring that users can only access fully available offline pages, you can prevent frustration caused by missing content. This requires a well-designed data model that tracks the reasons for offline availability.
2Utilize push notifications for syncing offline content to improve performance.Instead of relying on periodic polling, using push-based updates allows for more efficient synchronization of offline pages, reducing server load and improving user experience.
3Design your storage layer to support persistent offline access.Evolving from a simple caching mechanism to a persistent storage layer is crucial for ensuring that users have reliable access to their content without an internet connection.
Common Pitfalls
1
Failing to account for dynamic changes in page hierarchy can lead to stale offline content.
As pages and databases change, it is crucial to update the offline tracking system to reflect these changes. Neglecting this can result in users accessing outdated or incomplete information.