How can I enable reasonable default caching for public files in a Grails 3 application?

I have a Grails 3 application with images, css and js files in src / main / resources / public. They are obtained with no-cache headers:

Cache-Control:no-cache
Cache-Control:no-store
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified:Thu, 20 Aug 2015 06:35:30 GMT
Pragma:no-cache

How can I include a smarter strategy for these files, especially images? I do not want to use the asset pipeline, as this is a (mostly) javascript application, and we use JS tools to group files, etc.

+4
source share
1 answer

This can be configured in application.yml:

grails:
    resources:
        cachePeriod: -1

This allows default caching for static resources.

org.springframework.web.servlet.resource.ResourceHttpRequestHandler, org.grails.plugins.web.controllers.ControllersGrailsPlugin. If-Modified-Since 304 ..

.

0

All Articles