Jeff dePascale Blogging on and developing web and mobile technologies

25Jun/115

HTML5 manifest mime type in grails

I ran into an issue serving the proper mime type for a cache manifest from grails today, adding a 'manifest' key to grails.mime.types failed to register for some reason (if you know why, do tell!). Running on a server this can be addressed by setting the mime type directly in tomcat, but i needed to test locally using the built in Tomcat server. Hopefully this inability to serve a manifest mime type will be addressed soon, but in the meantime the workaround was to make the manifest a generated gsp and add the content-type declaration directly to the manifest:


<%@ page contentType="text/cache-manifest" %>CACHE MANIFEST
# rev 0
file.html

It's important to keep CACHE MANIFEST on the same line as the contentType property - manifests are discarded if they don't start from the first character with that declaration.

One last thing - this works better cross browser (where some browsers dont respect a manifest not ending in .manifest) by setting grails.mime.file.extensions to false, which will allow your mapping to be directly to cache.manifest, returning the rendered gsp.

Share This
  • LinkedIn
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • email
Filed under: General Leave a comment
Comments (5) Trackbacks (0)
  1. Awesome this helped greatly! The grails.mime.types setting didn’t work for me either >.<

  2. I actually figured out a way to do this without having to set grails.mime.file.extensions to false

    If you add the following:

    manifest
    text/cache-manifest

    To the

    src/war/web.xml

  3. Hmmm formatting stripped out my tag characters… trying again:


    manifest&glt;/extension>
    text/cache-manifest

  4. One more time with feeling!


    manifest
    text/cache-manifest

  5. Thanks for the tip! Really annoying how Grails just ignores that mime-type setting..


Leave a comment

(required)

No trackbacks yet.