forked from github/dataease
refactor: 优化系统升级后静态资源可能还是使用的历史的缓存版本造成错误的问题
This commit is contained in:
parent
067b8bc383
commit
847300acfd
@ -0,0 +1,40 @@
|
||||
package io.dataease.filter;
|
||||
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class HtmlResourceFilter implements Filter, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
|
||||
// 禁用缓存
|
||||
httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
|
||||
httpResponse.setHeader("Cache", "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.PRAGMA, "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.EXPIRES, "0");
|
||||
// 继续执行过滤器链
|
||||
filterChain.doFilter(servletRequest, httpResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user