You need to make a choice between a web app or a native app, and, of course, a third option, Hybrid app.
Now more and more mobile phone users, computer terminal browser is also constantly upgrading, innovation, Web page has not only used to share information so simple, can be used to do more things.
Local Storage upgrade
In the past, browsers did not have much storage power. HTML5 has made significant improvements in storage, providing localstorage and Sessionstorage objects for storage of small data, and more webdatabase to store large amounts of data.
Limitations of cookies and cookies
HTTP itself is a stateless non-link protocol, when users request an action on the browser, the server does not know what the user did last action, so if you want to store the injected login or not, the logged in text and other state information is very troublesome. The invention of cookies satisfies most of the requirements of state storage. Essentially, a cookie is a piece of text stored in a client (browser) that we can either set cookies on when the server responds, or modify it through JavaScript at the front end. Cookies have domain limitations, and cookies in different domains do not affect each other and are not accessible to each other.
You can enter Document.cookie in Google Chrome's console to view all available cookies on the current webpage, or you can set a cookie in such a way document.cookie= "uid=123", which does not overwrite the previous cookie , but is automatically added to the back of the original cookie, with different key-value pairs ";" Separated. In addition to domain limitations, there is a large and small limit on the size and quantity of our data storage. Different browsers use different throttling strategies, but not many.
Web Storage from HTML5
Compared to cookies, the WebStorage in the HTML5 specification is more suitable for use as a local data store. Web storage are easy to use, faster and more secure, and will only be stored in the browser and not sent to the server side with HTTP requests. It can easily store large amounts of data without compromising your site's performance.
Web Storage Use
The browser has built up two objects that have been instantiated, one sessionstorage and the other is localstorage.
The data stored in Sessionstorage is only valid during a single-page session, and Sessionstorage is more like a global variable on a page. The localstorage data is persisted to the client and will never expire (the cookie can be set to expire) and its capacity will not be as restrictive as the cookie.
Either Sessionstorage or localstorage, you can use these methods or properties as follows:
SetItem (key,value)???? GetItem (key)???? RemoveItem (key)???? Length???? Key (n)???? Clear ()
The difference between the two is that the declaration period of the stored data is different, as long as continuous access within the domain, the data stored in Sessionstorage will always exist, once the page or browser is closed, all sessionstorage stored data will disappear (that is, Sessionstorage does not deposit data to disk).
Storage Events
All modifications made to the storage object trigger the storage event on the document. Where the event object will have the following properties:
Domain???????? Key???? OldValue???? NewValue
For example:
Document.addeventlistener ("Storage", function (e) {console.log ("storage Changed"). Name ' "+ E.key +" ' "); });
Because this event has compatibility issues, it is generally not recommended.
Of course, not to say that localstorage size can be unlimited use, for different browsers, there is not the same settings, but generally will give each domain has 5MB of storage space, which for most applications, is enough.
Caching and application caching
HTML5 provides a unique caching mechanism: Application cache (Application caching)
As the name implies, this is an application-born caching mechanism. It is mainly possible to cache the server-side resource files locally, at least three of the following:
Accelerates application startup---saves time downloading files
Offline access--use offline cached pages and file resources to continue unfinished work
Save server resources-fewer requests mean less server pressure.
Basic use of the application cache
Generally, it is enabled for single-page apps.
Manifest
Opening the app cache in the document is simple, just add a manifest attribute to the HTML tag and specify the manifest file.
<! DOCTYPE html>
The HTML file itself is bound to be cached
And Appcache.manifest is actually a text file that specifies the resources that need to be cached by the browser, such as the following:
CACHE MANIFEST
Index.html
Stylesheet.css
Images/logo.png
Scripts/main.js
When the browser loads the page for the first time, it reads the file, downloads and caches the resources it specifies, and caches four files in the example above, because the cache is one-off, so if any of the four files are unavailable, the entire cache behavior will fail. In addition to the four files specified in the file that require caching, the HTML document that specifies the manifest file is also cached.
From WEP page to application