HTML 5 Application cache (bottom)

Source: Internet
Author: User
Tags browser cache

Manifest file
The manifest file is a simple text file that tells the browser what to cache (as well as what is not cached).

The manifest file can be divided into three parts:

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
The manifest file above lists three resources: a CSS file, a GIF image, and a JavaScript file. 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
The following NETWORK section stipulates that the file "Login.asp" is never cached and is not available offline:

NETWORK:
Login.asp
You can use an asterisk to indicate that all other resources/files require an Internet connection:

NETWORK:
*
FALLBACK
The FALLBACK section below specifies that if an Internet connection cannot be established, replace all files in the/html5/directory with "offline.html":

FALLBACK:
/html5//404.html
Note: The first URI is a resource and the second is a substitute.
Update cache
Once the app is cached, it remains cached until the following happens:

User empties browser cache
The manifest file is modified (see tips below)
App Cache updated by program
Instance-Full Manifest file
CACHE MANIFEST
# 2012-02-21 v1.0.0
/theme.css
/logo.gif
/main.js

NETWORK:
Login.asp

FALLBACK:
/html5//404.html
Important NOTE: "#" begins with a comment line, but can also be used for other purposes. The app's cache is updated when its manifest file changes. If you edit a picture, or modify a JavaScript function, these changes are not re-cached. Updating the date and version number in the comment line is a way to enable the browser to re-cache the file.
Notes about the application cache
Keep an eye out for cached content.

Once the file is cached, the browser continues to show the cached version, even if you modified the file on the server. To ensure that the browser updates the cache, you need to update the manifest file.

Note: Browsers may have a different capacity limit for cached data (some browser settings are limited to 5MB per site).

HTML 5 Application cache (bottom)

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.