0

I am building a Grails app that will utilize HTML5's Offline Mode. In that article, the author talks about the requirement for your web server to not cache something called the "Cache Manifest" file:

So here’s one thing you should absolutely do: reconfigure your web server so that your cache manifest file is not cacheable by HTTP semantics.

So I need to figure out how to tell Grails (2.4.x) not to allow clients to cache a particular file. I found this answer but am not confident it is the generally-accepted "Grails way" of doing this.

So I ask:

  • Is that answer the generally-accepted way of prohibiting a file from being cached in Grails? If not, then what is?; and
  • If it is, then what is CacheFilters, where do I define it, and are there any docs on its all, before, after, afterView, etc. methods?
Community
  • 1
  • 1
smeeb
  • 27,777
  • 57
  • 250
  • 447
  • 1
    How are you serving your file, is it just laying around in web-app/ ? – Oliver Tynes Nov 11 '14 at 08:57
  • Thanks @Oliver Tynes (+1) - yes, it will be in `web-app`. – smeeb Nov 11 '14 at 12:22
  • I cannot tell if this is indeed the best aproach, but I had use it with success and it's quite simple. About your second concern, the Filters are predefined "rules" that run along each matching server request; they are very usefull for security checks, manipulate headers, etc. There is plenty of documentation about them in [link](http://docs.grails.org/2.2.1/guide/single.html#filters) – jmendiola Jun 01 '16 at 13:27

1 Answers1

0

You cannot easily control the headers in a web-app file as far as I know.

A quick workaround for now could be to map /cache.manifest to a controller action in the urlmappings and simply set the header manually.

In the action you can do something like this after setting the appropiate headers:

response.outputStream.write(grailsApplication.applicationContext.getResource("/cache.manifest").getFile().bytes)

Coded freehand, but you get the general idea.

Oliver Tynes
  • 954
  • 4
  • 11