In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today I will tell you what the two storage methods of html5 refer to. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
The two storage methods of html5 are: 1, application cache (application cache), web applications can be cached, even without the network can be used; 2, local storage (localStorage or sessionStorage), you can store data on the client.
The operating environment of this tutorial: windows7 system, HTML5 version, Dell G3 computer.
1.Application Cache
HTML5 introduces application caching, which means that web applications can be cached, even without a network.
Application cache has three characteristics.
Offline browsing
Cached resources load faster
Reduce server load, and browsers will download only updated or changed resources from the server
To use it is to add a manifest attribute to the html tag
Each page with a specified manifest is cached when the user accesses it. If the manifest attribute is not specified, the page is not cached (unless the page is specified directly in the manifest file).
The recommended file extension for the manifest file is ".appcache".
The content of the document.
A manifest file is a simple text file that tells the browser what is cached (and what is not cached).
The manifest file can be divided into three parts:
CACHE MANIFEST-the files listed under this heading will be cached after the first download
NETWORK-the files listed under this heading require a connection to the server and will not be cached
FALLBACK-the file listed under this heading specifies the fallback page (such as 404 page) if the page is inaccessible.
A complete manifest file
CACHE MANIFEST # 2012-02-21 v1.0.0/theme.css/logo.gif/main.jsNETWORK:login.aspFALLBACK:/html5/ / 404.html2. Local Stora
HTML5 provides two new ways to store data on the client:
LocalStorage-data storage with no time limit
SessionStorage-data store for a session
Previously, all this was done by cookie. But cookie is not suitable for storing large amounts of data because they are passed by each request to the server, which makes cookie slow and inefficient.
Both localStorage and sessionStorage have the same operation methods, such as setItem (), getItem (), removeItem (), etc.
The methods of localStorage and sessionStorage:
SetItem Storage value
Purpose: store value in key field
Usage: .setItem (key, value)
Code example:
SessionStorage.setItem ("key", "value"); localStorage.setItem ("site", "js8.in")
GetItem gets value
Purpose: to obtain the value stored locally by the specified key
Usage: .getItem (key)
Code example:
Var value = sessionStorage.getItem ("key"); var site = localStorage.getItem ("site")
RemoveItem Delete key
Purpose: delete the value stored locally by the specified key
Usage: .removeItem (key)
Code example:
SessionStorage.removeItem ("key"); localStorage.removeItem ("site")
Clear clears all key/value
Purpose: clear all key/value
Usage: .clear ()
SessionStorage is not a persistent storage and will be cleared when the browser is closed. On the other hand, localStorage is used for persistent local storage, and the data will never expire unless it is actively deleted.
Html, the full name of html, is a markup language that contains a series of tags. Through these tags, you can unify the format of documents on the network and connect scattered Internet resources into a logical whole. Html text is a descriptive text composed of html commands, and html commands can explain text, graphics, animation, sounds, tables, links, etc. Mainly used with css+js to build elegant front-end web pages.
These are the two storage methods of html5 refer to the whole content of what, more and what the two storage methods of html5 refers to what related content can search the previous articles or browse the following articles to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.