bcfuchs / uredb_website

grails app for web access to the Ure Museum Collections
MIT License
1 stars 2 forks source link

set cache-control headers for static resources #151

Closed bcfuchs closed 8 years ago

bcfuchs commented 8 years ago

There are several ways to do this.

  1. Via a front-end proxy.

For apache httpd 2.4

Header set Cache-Control "max-age=1209600, public" "expr=%{REQUEST_URI} =~ m#.(ico|pdf|flv|jpg|jpeg|png|gif)$#"

Note this wont work in < 2.4 -- expr= support first in 2.4

  1. Via a custom Mapper for the resources plugin, as explained here: http://grails-plugins.github.io/grails-resources/guide/6.%20Creating%20custom%20mappers.html
  2. Via the cached-resources plugin

http://grails.org/plugin/cached-resources

  1. Potentially via a servlet filter, tho I couldn't get this to work for static resources

I chose option 2.