如何在Spring Boot中启用浏览器缓存

如何在Spring Boot中启用浏览器缓存,第1张

如何在Spring Boot中启用浏览器缓存

事实证明,这很容易解决。

目录结构为classpath:/ static / assets。要不向响应添加缓存控制标头,请添加此类:

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

仍然让我感到困惑的是,“无存储”是spring-boot的默认设置。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5641504.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存