


Detailed explanation of several examples of html5 storing data on the client
1.Application Cache
HTML5 introduces application cache, which means that web applications can be cached and can be used even without a network.
The application cache has three characteristics
Offline browsing
Cached resources Faster loading
Reduce server load, the browser will only download updated or changed resources from the server
The method of use is to Add a manifest attribute to the html tag
Each page with a specified manifest will be cached when the user accesses it. If the manifest attribute is not specified, the page will not be cached (unless it is specified directly in the manifest file).
The recommended file extension for manifest files is: ".appcache".
<!DOCTYPE HTML> <html manifest="demo.appcache"> <body> The content of the document...... </body> </html>
Manifest files are simple text files that tell the browser what is cached (and what is not cached).
Manifest files can be divided into three sections:
CACHE MANIFEST - 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 files listed under this heading require a connection to the page Fallback page when inaccessible (such as 404 page)
CACHE MANIFEST # 2012-02-21 v1.0.0 /theme.css /logo.gif /main.js NETWORK: login.asp FALLBACK: /html5/ /404.html
- localStorage - data storage without time limits
- sessionStorage - Data storage for a session
Methods of localStorage and sessionStorage:
Purpose: Store value into the key field
Usage: .setItem(key, value)
Code example:
sessionStorage.setItem("key", "value"); localStorage.setItem("site", "js8.in");
Usage: Get the locally stored value of the specified key
Usage: .getItem(key)
Code example:
var value = sessionStorage.getItem("key"); var site = localStorage.getItem("site");
Usage: Delete the specified key Locally stored value
Usage: .removeItem(key)
Code example:
sessionStorage.removeItem("key"); localStorage.removeItem("site");
Usage: clear all Key/value
Usage: .clear()
sessionStorage is not a persistent storage and will be cleared after the browser is closed. LocalStorage is used for persistent local storage. Unless the data is actively deleted, the data will never expire.
3.indexDBindexDB is a lightweight NOSQL database. It is more efficient than web sql (sqlite), including indexing, transaction processing and robust query functions. Its features include:- A website may have one or more IndexedDB databases, and each database must have a unique name.
- A database can contain one or more object stores. An object store (uniquely identified by a name) is a collection of records. Each record has a key and a value. The value is an object that can have one or more properties. Keys may be based on a key generator, derived from a key path, or set explicitly. A key generator that automatically generates unique consecutive positive integers. The key path defines the path to the key value. It can be a single JavaScript identifier or multiple identifiers separated by periods. (Somewhat like the characteristics of a column database)
- In IndexedDB, almost all operations use the command->request->result method. For example, query a record, return a request, and get the query result in the result of the request. Another example is opening a database, returning a request, and getting the returned database reference in the result of the request.
- indexedDB needs to be placed on the web server before it can run.
The above is the detailed content of Detailed explanation of several examples of html5 storing data on the client. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.
