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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -