HTML 5 Application cache manifest, cache manifest

Source: Internet
Author: User

HTML 5 Application cache manifest, cache manifest
What is Application Cache )?

HTML5 introduces application caching, which means that web applications can be cached and accessed when there is no Internet connection.

Application caching brings three advantages to applications:

  • Offline browsing-users can use them when the application is offline
  • Speed-cached resources are loaded faster
  • Server Load Reduction-the browser will only download updated or changed resources from the server.
Browser support

All mainstream browsers support application caching, except Internet Explorer.

 

Usage:To enable application caching, add the manifest attribute to the

<!DOCTYPE HTML>

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 in the manifest file ).

The recommended file extension for the manifest file is: ". appcache ".

Please note that the manifest file needs to be configuredCorrect MIME-typeText/cache-manifest ". Must be configured on the web server.

Manifest File

A manifest file is a simple text file that informs the browser of cached content (and non-cached content ).

The manifest file can be divided into three parts:

  • CACHE MANIFEST-Files listed under this title will be cached after the first download
  • NETWORK-The files listed under this title need to be connected to the server and will not be cached
  • FALLBACK-The files listed under this title specify the rollback page (such as the 404 page) when the page cannot be accessed)
CACHE MANIFEST

The first line, cache manifest, is required:

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

The above manifest file lists three resources: a CSS file, a GIF image, and a JavaScript file. After the manifest file is loaded, the browser downloads the three files from the root directory of the website. Then, these resources remain available no matter when the user is disconnected from the Internet.

NETWORK

The following NETWORK section specifies that the file "login. asp" will never be cached and is unavailable offline:

NETWORK:login.asp

You can use asterisks to indicate that all other resources/files require Internet connection:

NETWORK:*
FALLBACK

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

FALLBACK:/html5/ /404.html

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

 

Usage:

1. Add

2. Create a New notepad, enter the content, name it myweb. appcache, and upload it to the corresponding directory of the website manifest.

3. Browse the page offline and reload the page. Check whether the scripts and images on the page are still available.

Related Article

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.