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?

Charles
  • 50,943
  • 13
  • 104
  • 142
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
  • The Chrome console says "Application Cache Error event: Manifest fetch failed (404) http://www.phillipsenn.com/Index/AppCache/example.appcache". Maybe my shared server provider doesn't allow the appcache extension. – Phillip Senn Nov 16 '11 at 21:44
  • If I change it to a .txt, now Chrome says "Application Cache Error event: Invalid manifest mime type (text/plain) http://www.phillipsenn.com/Index/AppCache/Appcache.txt" – Phillip Senn Nov 16 '11 at 21:45

3 Answers3

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:

robertc
  • 74,533
  • 18
  • 193
  • 177
  • 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 missing – Martin Belcher - AtWrk Oct 11 '13 at 11:33
  • 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. – Ryan Anderson Jan 08 '14 at 16:40
  • If you add it in web.config, you probably need to remove the default mapping. , then add text/cache-manifest. – Andy Wiesendanger Sep 16 '15 at 13:51
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

Mychal Hackman
  • 319
  • 1
  • 8
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

Perception
  • 79,279
  • 19
  • 185
  • 195
CF GRugan
  • 21
  • 1