java - Set setCachePeriod for static resources in spring boot -
i using spring boot, , /static served static resources js , css, far good, while want set cache header of these files, tried this:
@configuration public class basemvcconfig extends webmvcconfigureradapter { @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/static/**").addresourcelocations("classpath:/static/").setcacheperiod(24 * 3600 * 365); } } however after that, application can not serve /static folder.
what's problem?
in opinion, it's better use spring.resources.cache-period property set cache period of default boot resource handler. add following application.properties:
spring.resources.cache-period = 31536000 and delete basemvcconfig config file.
Comments
Post a Comment