Introduction
In this chapter, you will learn how to store and retrieve data from a local device when there is no Internet access. This is important for some apps because of their specific use cases. For example:
- The data does not need to be stored in the server
- It's faster to store data locally and sync it to the server using background processing
- The app must work locally and send data to the server when it's online again
There are several methods for offline data persistence.
- In the past, you probably leveraged cookies in some aspects to store session data such as information regarding whether a user has visited a certain page. Cookies are used for very basic use cases because of their size limitation (4,095 bytes). Cookies are sent to a server on each HTTP request so that the server also has access to this information. This may result in a waste of bandwidth.
- Browsers today have Local Storage support, which is a better method. Local Storage can store up to 5 MB of data and is available...