HTML5 Application Cache

Source: Internet
Author: User

With HTML5, creating a cache manifest file makes it easy to create an offline version of your Web app.

Application caching brings three benefits to your app:

    1. Offline Browsing-users can use them when the app is offline
    2. Speed-cached resources are loaded faster
    3. Reduce server load-The browser will download only updated or changed resources from the server.
Cache Manifest Basics

To enable application caching, include the manifest attribute in the

1 <! DOCTYPE HTML > 2 <  manifest= "Demo.appcache">3 ... 4 </ HTML >

Pages that specify manifest are cached when the user accesses them. If the manifest attribute is not specified, the page is not cached

Manifest file
    • Cache MANIFEST -Files listed under this heading will be cached after the first download
    • NETWORK -Files listed under this heading require a connection to the server and are not cached
    • FALLBACK -Files listed under this heading provide a fallback page when the page is inaccessible (e.g. 404 pages)
CACHE MANIFEST

The first line, CACHE MANIFEST, is required

CACHE Manifest/theme.css/logo.gif/main.js

When the manifest file is loaded, the browser downloads the three files from the root directory of the Web site. These resources are then available, regardless of when the user disconnects from the Internet.

NETWORK

"Login.php" is never cached and is not available offline

FALLBACK
1 FALLBACK: 2 /html//offline.html

The first URI is a resource, and the second is a substitute.

Offline: "offline.html" instead of/html5/

Complete Manifest file
1 CACHE MANIFEST 2 # 2012-02-21 v1.0.0 3 /theme.css 4 /logo.gif 5 /main.js 6 7 NETWORK: 8 login.php 9 Ten FALLBACK:  /html//offline.html

HTML5 Application Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.