refactor(系统设置): 修改http缓存逻辑

This commit is contained in:
wangjiahao 2024-03-27 15:02:57 +08:00
parent 3a4daa48b0
commit 33edd9b3be

View File

@ -13,7 +13,7 @@ import java.io.IOException;
@Component @Component
public class HtmlResourceFilter implements Filter, Ordered { public class HtmlResourceFilter implements Filter, Ordered {
@Value("${dataease.http.cache:true}") @Value("${dataease.http.cache:false}")
private Boolean httpCache; private Boolean httpCache;
@Override @Override
@ -28,7 +28,7 @@ public class HtmlResourceFilter implements Filter, Ordered {
@Override @Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
if(httpCache!=null && httpCache){ if(httpCache == null || !httpCache){
// 禁用缓存 // 禁用缓存
httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache"); httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
httpResponse.setHeader("Cache", "no-cache"); httpResponse.setHeader("Cache", "no-cache");