Managing Offline Data

You need to consider where offline data is stored: In localStorage or a database, for example IndexedDB or PouchDB?

Another consideration is how much data will the application store on a device? The business functionality included in an application will determine data volume. Consider the practicality of storing gigabytes of data.

You also need to decide the appropriate format for offline data. Are key and value pairs adequate? Will the application require indexes for query optimisation?

localStorage:

Operates synchronously; i.e. the application blocks the user while it retrieves the data.

Capacity is approximately 5MB

No built-in security

Inappropriate for storing user credentials

Databases can be larger than localStorage.

IndexedDB:

Key, value pairs

Understands transactions

Asynchronous via a call back function

No size limit; browsers may impose a limit or clear data when space is low

PouchDB:

Builds on IndexedDB

Includes synchronisation options