Appearance
This documentation aims to provide a clear and well-structured guide to implementing offline support in Aeppic. To achieve this, we'll address two key components: static assets, data models, and authentication information.
Please note that Aeppic does not directly configure caches or service workers. It provides tools for these purposes, but the application itself needs to be configured to utilize them effectively.
Requirements for Offline Support
To ensure compatibility with offline support, your browser must support the following features:
- IndexedDB: Check compatibility here.
- Service Worker: Check compatibility here.
These features are supported by all modern evergreen browsers.
Static Assets
The @aeppic/server
hosts all static assets, including the SPA HTML template and the API endpoint. To enable caching, these assets must be downloaded. While you can use any service worker to implement this, the Aeppic project includes one: @aeppic/service-worker
.
The @aeppic/service-worker
project handles client-side caching strategies for browsers. It operates alongside the /api/v4/statics/_list
endpoint and the Statics Configuration. Setting this up is essential for offline support.
Data Model
For offline functionality, the client needs to support all operations as if the server were available. This includes all CRUD operations, client-side business rules, and commands. The data model should accommodate these requirements, even when offline. To achieve this, the relevant data must be included in the cache.
Boot Sequence
During the initial startup of Aeppic in the browser, several processes occur, depending on how it's embedded in the HTML. By default, calling Aeppic.renderLayout
renders the ae-root
component into the designated DOM element. The system then retrieves documents from the server and performs queries. For a successful offline user experience, all requests must have been loaded into the data model cache.
Data Consistency
Maintaining data consistency is crucial for operational offline mode. The caching layer ensures a consistent view of the data model, even when online and subject to changes from connected clients. Local document changes are first applied locally and written to a change queue. The difference in offline mode is that the document and the change queue are written to IndexedDB when no server connectivity is available or when offline mode was switched on.
Security
When configured for offline mode, Aeppic saves the last authenticated user information and assumes that user is still logged in. Logging off does not delete any pending changes by default (for data safety reasons), and these changes are not encrypted. If untrusted user scenarios are a concern, the application may implement an interactive user process before logging out to inform the user about potential data loss. If necessary, pending changes can then be deleted.