Copyright statement: This article is the original article for the blogger, without permission may not be reproduced.
HTML5 offline tour need to set the offline file list (manifest), manifest need to set the MIME type, so that the correct identification of the MIME type, the type of error is not offline. Different servers have different settings, here is an introduction to the configuration of the HLTM5 Tomcat offline storage.
1, in the Tomcat installation directory to find conf/web.xml to add a mime_type, can be added to any location within, of course, in the vicinity of the mime-mapping other tags easy to manage and maintain.
<Mime-mapping> <Extension>Manifest< /Extension> <Mime-type>Text/cache-manifest< /Mime-type> < /Mime-mapping>
2, the preparation of.Manifest documents.
File name can be casually named, I was my.manifest
MANIFEST CACHE #VERSION 3.9 # direct cache file CACHE: /html5cache/test.html /html5cache/ebt.png # in time online file NETWORK: /html5cache/test.js /html5cache/damicTest.jsp # alternative FALLBACK:
3, write offline cache HTML file
<! Html> DOCTYPE <HTML Manifest="/html5cache/test.manifest"> <Head> <Meta Charset="UTF-8"> <Title>Offline caching of HTML5 features< /Title> < /Head> <Body> < /Body> < /HTML>
The key word is above.
- expansion of reading -
HTML5 implementation offline applications
1), Apache, nginx, or IIS support.Manifest file
In the front of the Apache, # removed, offline storage can make service components to support HTML5.
2), create a manifest file
MANIFEST CACHE header file header Is a comment #This CACHE offline storage file Style.css NETWORK file that requires network calls Search.jsp Update file when FALLBACK resource is invalid or unavailable Test.html
3), the associated manifest file to the HTML document
Browser compatibility reference:
IE: does not support
HTML5 offline content update
* update cache
* automatic updates
Browser in addition to the first time to access the Web application cache resources, only when the manifest cache file itself changes to update the cache. The resource file in manifest cache changes and does not trigger updates.
* manual update
Developers can also use the window.applicationCache interface to update the cache. Method is to detect the value of window.applicationCache.status, if it is UPDATEREADY, then you can call window.applicationCache.update () to update the cache. The demo code is as follows.
- Guess you're looking for