如何在spring boot中启用浏览器缓存

我正试图让Spring启动让浏览器缓存静态资源。 我的资源位于“静态”下的类路径中。 当我查看发回的标头时,我看到修改标头设置正常,但不知何故,标题“Cache-Control:no-store”也被添加。

HTTP/1.1 200 Last-Modified: Wed, 24 Aug 2016 08:50:16 GMT Cache-Control: no-store Accept-Ranges: bytes Content-Type: text/css Content-Length: 434554 Date: Wed, 24 Aug 2016 09:42:42 GMT 

我已经看到了这个答案如何在Spring Boot中启用HTTP响应缓存 ,但这似乎并不适用于我,因为我没有使用spring-security,它不在类路径上。

我正在使用带有百里香的sp​​ring-boot 1.4.0。

那么,如何让spring boot不包含Cache-Control头?

事实certificate它很容易解决。

目录结构是classpath:/ static / assets。 要没有向响应中添加缓存控制头,请添加以下类:

 @Configuration public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/static/assets/").setCacheControl(CacheControl.empty()); } } 

它仍然让我感到困惑的是,“no-store”是spring-boot的默认设置。