Java – how to enable reasonable default caching for public files in Grails 3 applications?
•
Java
I have a Grails 3 application with images, CSS and JS files under Src / main / resources / public These use the 'no cache' header to provide:
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 do you enable more reasonable policies for these files, especially images? I don't want to use asset pipeline because it is a (most) JavaScript application. We use js tools to bundle files and so on
Solution
This can be found in application Configuration in YML:
grails: resources: cachePeriod: -1
This enables browser default caching for static assets
Resources by org springframework. web. servlet. resource. Resourcehttprequesthandler, which is provided by org grails. plugins. web. controllers. Controllersgrailsplugin configuration The handler supports if modified since and 304 status codes
I can't find any references in the document
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码