16.4 storage of structured data
As we can see above, when using storage to save the key-value pair, the key and value can only be strings, which is sufficient for simple data. However, if you need to save more complex data,
For example, you can save the data similar to the table record, so you can combine the JSON knowledge described above.
To store structured data, follow these steps:
Encapsulate structured data into JSON objects.
Convert the JSON object to a string and save it.
To read data, follow these steps.
Reads a string in JSON format.
Converts a string in JSON format to a JSON object.
Extract data using JSON object attributes.
16.2 offline applications
Client storage usually needs to be used together with offline applications. The most common application methods can be divided:
When a user is online and can connect to the server, the data is directly submitted to the server for direct interaction with the server.
When a user is offline and cannot connect to the server, the user browses and operates offline applications, so that the user can use the web application even if the user does not have a network, when operating offline applications, all data is stored locally.
When the user accesses the network again, the Web application control submits the data stored in the local storage to the remote server.
Offline applications can cache some or all pages in the browser, so that users can operate on this offline application even if they are not connected to the Internet.
16.2.1 differences between offline applications and browser cache
Before introducing offline applications, some may confuse offline applications with browser cache because browser cache can also cache webpages. But in fact, there are essential differences between offline applications and browser cache.
Different services: Offline Application Control caches the entire web application. Offline applications provide an offline website service function, while browser cache simply caches webpages.
Different reliability: offline applications can precisely control the resources that the browser needs to cache, which is very reliable. However, browser caching relies entirely on browser behavior and has a certain degree of reliability.
Different controllability: offline applications can accurately control the resources cached and refresh the cache. However, browser cache is completely dependent on browser behavior, and programs cannot control cache behavior.
August 20 = 441-445