Application Cache manifest
Asked Answered
E

3

6
<!DOCTYPE HTML>
<html manifest="example.appcache">
<link rel="stylesheet" type="text/css" href="AppCache.css">
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<p>Test to make sure css is being cached</p>
<img src="large.jpg">
<script src="AppCache.js"></script>
</body>
</html>

My example.appcache file has:

# v1 11/16/2011
AppCache.htm
AppCache.js
AppCache.css
large.jpg

The first time I navigated to the page, it asked

This website is asking to store data on your computer for offline use.

When I take Firefox offline and press refresh, the jpg disappears.

Q: What do I need to do to make sure the image is cached locally?

Erythrite answered 16/11, 2011 at 21:40 Comment(2)
The Chrome console says "Application Cache Error event: Manifest fetch failed (404) phillipsenn.com/Index/AppCache/example.appcache". Maybe my shared server provider doesn't allow the appcache extension.Erythrite
If I change it to a .txt, now Chrome says "Application Cache Error event: Invalid manifest mime type (text/plain) phillipsenn.com/Index/AppCache/Appcache.txt"Erythrite
P
18

IIS does not serve unknown file types. You need to configure it to serve .appcache files with the MIME type text/cache-manifest, how you do this depends on which version of IIS you have:

Psychomotor answered 17/11, 2011 at 0:36 Comment(3)
A gotcha for those using ASP.NET projects, make sure you change the Build Action from None to Content within your VS project otherwise the file will not be in your build output and hence really will be 404 missingArtificiality
For what it's worth, new (current) versions of most browsers now accept an appcache that doesn't have the cache-manifest MIME type. However, IE11 still requires it, so it is best to make sure it is set. Robert is correct in that IIS will not serve files with unknown extension.Bracteate
If you add it in web.config, you probably need to remove the default mapping. <remove fileExtension=".manifest" />, then add text/cache-manifest.Leakage
V
9

I just want to comment on the accepted answer here, as the mimetype mentioned does not work (at least in IIS7.5). The correct mimetype is:

text/cache-manifest

See: https://developer.mozilla.org/en/Using_Application_Cache

http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline

Viniculture answered 16/12, 2011 at 17:8 Comment(0)
A
2

Do not forget that you need

CACHE MANIFEST

At the top of you manifest document. It is required.

CACHE MANIFEST
# v1 11/16/2011
AppCache.htm
AppCache.js
AppCache.css
large.jpg

That should do the trick

Amey answered 7/5, 2012 at 0:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.