HTML5 Application Cache Usage Experience

Source: Internet
Author: User

The recent project to use the offline cache, I thought that the use of HTML5 application cache is so easy, should be able to fix it soon, the result still met a lot of _ _ _!!!

Without saying much, HTML5 basic introduction, see W3cschool.

1, manifest file cache manifest There is no colon, and network: and fallback: after adding a colon;

Do not ask why I write this first, are to see the tutorial is not serious mistakes, I hope you do not make such a low fault!

2. NETWORK: You can use an asterisk (*) to denote all other files, but the cache manifest section must specify each file to be cached

The following wording is not feasible:

*img/**.js*/a.png

The console can see the following information:

Think a lazy can not, beginning still in the heart scold designer stupid! But you can only think of this design ( the actual reason may not be so, here is only a personal understanding ), the application cache in the update cache manifest the specified file is to get files from the server, if I lazy write a *, But there seems to be no server is supported to a directory address to put all the files in the directory back to you, so still honestly write down all the files to be cached (many files, too lazy to write files can be merged).

3. The files listed in the cache manifest section must exist, otherwise the cache will expire.

This is a little understanding, does not exist on the cache is, why do not cache!!!

The console will see this information:

  

Judging from the error message, the same as the previous one, the browser will take the cache manifest part as a resource address (relative path).

4. After the manifest file is updated, the first visit of the browser shows the cached file, and the updated file is displayed again.

After updating the manifest file, the browser first accesses the console with the following information, indicating that the cache file has been updated, which is shown later or cached previously

The latest cache files are displayed at a later time, and the console information is as follows:

This feature is well understood, an important function of application caching is to speed up the loading of resources, if the first access to display the latest resources directly, then the first visit will not enjoy the benefit of the application cache.

5. If the resources listed in the manifest file have special characters, please encode the URL

HTML5 Application Cache Usage Experience

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.