HTML 5 Cache mechanism: Cache Manifest configuration instance, cachemanifest

Source: Internet
Author: User

HTML 5 Cache mechanism: Cache Manifest configuration instance, cachemanifest

Cache Manifest is a caching mechanism of HTML 5. The author uses the blog as the test environment directly, although [color = #444444! Important] The application is very simple, but the effect is surprisingly good. The cache speed is amazing. As Yslow shows, it takes only 0.729 seconds to open a cached page, which is about 10 times faster than that without caching.
I. Basic knowledge about Cache Manifest
As a Web developer, the word Cache is rarely heard or seen. Yes, as mentioned above, it is a cache mechanism. It can use a. manifest file to configure files that need to be cached or must be cached online. The focus is on this. manifest file, which has been simply organized here:
◆ Mime type: text/cache-manifest
◆ NAME. manifest
◆ Role: Mainly configure the files to be cached
Ii. How to Implement
The implementation is very simple (of course, this is also a problem. We will talk about the solution later). The implementation steps are as follows:
1. Add mime type support to the server
For example, you can add:

The following is a reference clip:
AddType text/cache-manifest

2. Create NAME. manifest:

The first line of the cache manifest mark must be available, and the CACHE/NETWORK/FACKBACK is optional. If no logo is written, the Cache is cached by default. Cache is unnecessary. NETWORK refers to pages that do not want to be cached, such as login pages. FALLBACK refers to an alternative solution when no response is received, for example, if I want to request a page but the server of this page is down, I can display another specified page with the following file structure:

The following is a reference clip:
CACHE MANIFEST
# VERSION 0.3
# Directly cached files
CACHE: abc.html
Images/sofish.png
Js/main. js
Css/layout.css
# Files that require online time
NETWORK:
/Wp-admin/
# Alternative
FALLBACK :/
Ajax/ajax.html

How to update this configuration file? As long as you change the file content, the above # VERSION 0.3 is actually only a line of comment, but the file can be cached again, so that you can write the VERSION number and modify the VERSION number to cache it again when you want to update it, is a relatively recommended method, or even a best practice.
3. Add the manifest attribute to & html & tags

Http://html5.662p.com/thread-24-1-1.html


How to correctly set html5 cache Problems

Each file transmitted over the network has the mime type. This is in the http protocol. The server must correctly set the mime type of files with different suffixes, for more information, see.
# The comment is followed by the comment. You can delete it at will. You can understand that the time and version are generally written for debugging, because you have changed your program file, the browser will also get it from the cache. You must change your manifest file to update the local file. You can customize the manifest file method, the best way is to set the comment.


Html5 Cache Manifest application Cache cannot be implemented

The value address of your manifest attribute is incorrect.
<Html manifest = "/weixin_index.appcache">

You can view the local cache in the network in Firefox settings

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.