Search code examples
html5-appcache

html5 offline cache is caching all files instead of cached files that are listed


I am trying to use offline caching of html5. But problem is it is caching all html files and not the ones I mentioned in cache manifest file:
For ex: I have 4 html files: index.html, test.html, sample.html, fallback.html and I have sample.appcache manifest file that contains:

CACHE MANIFEST
index.html
sample.html
NETWORK:
test.html
FALLBACK:
/ /fallback.html

I dont have manifest="sample.appcache" attribute set in any html file. I am using JBoss 5 AS and in web.xml I added mime mappings as follows:

<mime-mapping>
    <extension>appcache</extension>
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>

So only index.html and sample.html needs to be cached offline but test.html is also getting cached if it was hit earlier when server was up. The fallback.html is not getting called when server is stopped in place of this test.html
What is wrong with this setup?
Second thing I did not understand is on IE(v9) and Firefox(v19) I don't have to set mime-mappings but for application to work on chrome(v26) and safari(v5.1.7) this setting is indeed mandatory.


Solution

  • I have not worked with JBoss, but the reason that Chrome and Safari want the MIME type for the appcache is because otherwise it has no way of identifying it as an cache manifest. Simple solution is to just include it :-P

    As for the caching, where are you seeing it cached? Is it for sure being stored in the offline section? Keep in mind that files will still be cached like normal regardless of the cache manifest.