Html5 offlline cache example

Source: Internet
Author: User

Comments: To use this api, make sure that the corresponding mime type is configured on the server side. Take tomcat as an example to describe it in detail, if you want to use this api, you must ensure that the corresponding mime type is configured on the server.

Take tomcat as an example. Open the Tomcat 6.0 \ conf \ web. xml file and add the following content at the end of the file:

The Code is as follows:
<Mime-mapping>
<Extension> manifest </extension>
<Mime-type> text/cache-manifest </mime-type>
</Mime-mapping>

Note that the value of extension is manifest, so the suffix of the cached file must be the same as that of the file.

The cache format must be as follows:

The Code is as follows:
<! DOCTYPE html>
<Html manifest = "/cache. manifest">
<Body>
...
</Body>
</Html>

Cache. mainfest is the file configured on the server.

The format is as follows:

The Code is as follows:
CACHE MANIFEST
Index.html
Time. js
Time.css
# Fallback is mainly used to replace files offline,
# All requests under/pay/ofline.html pay are forwarded to ofline.htm offline.
FALLBACK:
Server-time.js fallback-server-time.js
NETWORK:
*
# Version 9

The version is the version label. When the version changes, the client automatically updates the cache.

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.