Adding a MIME Type to NGINX

October 26, 2010 - 1 Comment


I’m implementing the HTML 5 offline caching mechanism in the iPhone interface of Turbine and to do that I need to expose a .manifest file. Per the specs, a .manifest file should be served with a content type of text/cache-manifest.

I can check this by submitting a HEAD request with curl and the -I switch:


~ >curl http://your-url/sample.manifest -I

HTTP/1.1 200 OK
Server: nginx/0.7.64
Date: Mon, 25 Oct 2010 21:59:58 GMT
Content-Type: application/octet-stream
Content-Length: 241
Last-Modified: Mon, 25 Oct 2010 21:58:20 GMT
Connection: keep-alive
Accept-Ranges: bytes

Oops, looks our web server, NGINX doesn’t associate a .manifest file with the content-type we need. To change this, you need to update the mime.types file in the conf directory. Depending on how you set up NGINX it could be located under /etc/nginx or /opt/nginx.

After opening the file, you should see something like this:


types {
  text/html      html htm shtml;
  text/css      css;
  text/xml      xml;
  ...
}

Simply add an entry “text/cache-manifest      manifest;” and re-start your server and you should be good to go. Check this again with curl:


~ >curl http://your-url/sample.manifest -I

HTTP/1.1 200 OK
Server: nginx/0.7.64
Date: Mon, 25 Oct 2010 22:17:51 GMT
Content-Type: text/cache-manifest
Content-Length: 241
Last-Modified: Mon, 25 Oct 2010 22:16:13 GMT
Connection: keep-alive
Accept-Ranges: bytes

Much better.

Programming Snippets Share/Save/Bookmark  Share or Save
1 Comment so far ↓
  1. Daniel says:

    January 12, 2012 at 12:44am

Leave a Reply
  • « Older Entries
  • Newer Entries »