In trying to add HTML5 Application Cache support to one of my web apps today, I hit a few little snags with my hoster (GoDaddy with a Shared Deluxe Windows account) and wanted to share as I’m sure other people will run into the same thing.
Each time I uploaded my web.config
file, I kept getting 500 server errors that weren’t very helpful. As it turns out, the extension .manifest
is already taken by the mime-type application/x-ms-manifest
, and when I tried to override that, IIS got kind of angry, and served the 500 Server error. I wasn’t quite sure what was happening, but was able to figure it out by reverting to my original web.config
file, and requesting the appcache.manifest
file that I had already uploaded. Sure enough, using the network tab in the Chrome DevTools, I saw it was being served back with the wrong mime type.
To resolve the issue, I added a new static file handler for .appcache
files in the system.web -> httpHandlers section. If you don’t do this, IIS doesn’t know about the file type and it won’t serve unknown file types at all. Then in system.webServer -> staticContent, I added a mimeMap extension for .appcache
files with the mimetype of text/cache-manifest
. After uploading the web.config
file again, I retried my request, and sure enough, everything worked perfectly!
My final web.config now looks like…
<configuration> <system.web> ... <httpHandlers> ... <add verb="GET,HEAD" path="*.appcache" type="System.Web.StaticFileHandler" /> </httpHandlers> </system.web> ... <system.webServer> ... <staticContent> <mimeMap fileExtension=".appcache" mimeType="text/cache-manifest" /> ... </staticContent> ... </system.webServer> ... </config>
Check out this tutorial on Application Cache at HTML5Rocks.com. Also, you can find a full list of the default mime types provided by GoDaddy’s IIS servers here.
[Update 6/30/11 @ 1:53pm] @Paul_Irish pointed out that the recommended extension is .appcache
specifically to avoid the unregistered Microsoft extension, and referred to a bug on HTML5.org. So there you have it!