HTML5 manifest mime type in grails 5

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.

5 thoughts on “HTML5 manifest mime type in grails

  1. Reply rockhowse Sep 14, 2011 2:20 pm

    Awesome this helped greatly! The grails.mime.types setting didn’t work for me either >.<

  2. Reply rockhowse Sep 14, 2011 3:49 pm

    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. Reply rockhowse Sep 14, 2011 3:51 pm

    Hmmm formatting stripped out my tag characters… trying again:


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

  4. Reply rockhowse Sep 14, 2011 3:52 pm

    One more time with feeling!


    manifest
    text/cache-manifest

  5. Reply Thomas Ferris Nicolaisen Dec 6, 2011 9:20 am

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

Leave a Reply