Support HTML5 offline storage in Tomcat

Label TomcatHTML5The serverstorageAdministration
391 people read comments(0) Collection Report

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.

    <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

# direct cache file

# in time online file
# alternative

3, write offline cache HTML file

    <! Html> DOCTYPE  
    <HTML Manifest="/html5cache/test.manifest">  
        <Meta Charset="UTF-8">  
        <Title>Offline caching of HTML5 features< /Title>  
        < /Head>  

        < /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.
Text/cache-manifest.Manifest AddType
2), create a manifest file

MANIFEST CACHE header file header
      Is a comment #This
CACHE offline storage file
NETWORK file that requires network calls
Update file when FALLBACK resource is invalid or unavailable

3), the associated manifest file to the HTML document

Browser compatibility reference:
IE: does not support
3.5+ Firefox:
4.0+ Safari:
5.0+ Chrome:
10.6+ Opera:
2.1+ iPhone:
2.0+ Android:

HTML5 offline content update
* update cache
Application can wait for the browser to automatically update the cache, you can also use the Javascript interface to manually trigger updates.
* 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
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • Visit1084 times
    • Integral:One hundred and fifty-nine
    • Grade
    • Rank:Thousands of miles away
    • Original15
    • Reproduced:3
    • Translation:0
    • Comments:0
    Classification of articles