我想在spring boot中设置禁用浏览器缓存(缓存控制:no-cache,no-store,max-age = 0)。
我的环境
spring-boot: 2.1.2
spring-security: not use
我搜索了如果我想设置响应头的缓存控制:无缓存,只需添加'application.yml'。
像这样
spring.resources.cache:
cachecontrol:
max-age: 0
no-cache: true
no-store: true
cache-private: true
要么
spring.resources.chain.cache: false
但它不起作用。
我无法在我的Chrome浏览器的响应标头中显示缓存控制标头。
在spring-framework中,我只是设置
<mvc:mapping path="/**"/>
<bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptor>
如何在没有spring安全性的情况下在spring boot中设置禁用浏览器缓存
谢谢。
尝试在application.properties中添加此行
spring.cache.type=NONE