H5 Application Caching-cache manifest

Source: Internet
Author: User

First, the role

Offline browsing-caches resources locally based on file rules, while still accessing resources offline, and networking directly with files cached locally. Optimize loading speed and conserve server resources.

Second, the application scenario

As Manifest's name: offline application caching , this feature is designed to be used by applications that have offline scenarios, such as mobile phone app/h5 that need to be used offline, or a purely static page on the PC side.

Iii. issues 1. Display lag after server resource update to refresh the page more than once
    1. The first time the page is loaded, the browser will determine if manifest is introduced and, if introduced, downloads and caches the resources by file rules.
    2. When the page is loaded again, the local cache is used based on the cache file specified in manifest instead of requesting server resources.
    3. When the manifest file is updated, the page load is already in progress, but the cache update is not yet complete, the file cached by the old manifest is first used, and the browser will download the cached file from the new manifest file, and if you want to see the latest static resources need to refresh the next page to reload.
2. Full load

When the manifest file is updated, all resources are downloaded once, and one of the exceptions causes the entire manifest to run abnormally.

3.W3C Standard and browser support

As a new attribute of the H5, the original intention is to construct the offline application, caching the Web site resources, the original browser caching mechanism (304) is very good, there is no need to use manifest cache; in fact, because the use of the response is not good, the internet is abandoning manifest.

Iv. Methods of Use

First specify the manifest configuration file in the label.

Configuration file Manifest.appcache.

CACHE MANIFEST# 井号备注,这边可以放版本更新时间,修改备注算更新 manifest 文件CACHE:# 首次下载 CACHE 后列出来的文件后缓存到本地。/favicon.ico/main.cssNETWORK:# NETWORK 下的文件不可被缓存,必须要与服务器连接。login.phpFALLBACK:# 一行放两个路径,第一个是访问资源,第二个是替补;当无法访问前一个资源时,用后一个资源代替之。/cat/ /404.html

Attention

Manifest will cache the current page, so if you want to update the current page, you can only update the manifest file first.

V. Summary

The manifest is suitable for applications that need to be run offline (timers, calculators, readers, etc.), and the need to frequently publish frequently updated sites is not an appropriate offline caching mechanism.

H5 Application Caching-cache manifest

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.