目前我有以下过滤器清除每个请求的缓存:
val rddStringToRowRDD = rdd.map(value => Row(value))
val dfschema = StructType(Array(StructField("value",StringType)))
val rddToDF = sparkSession.createDataFrame(rddStringToRowRDD,dfschema)
val rDDToDataSet = rddToDF.as[String]
请在下面找到退出方法:
public class CacheControlFilter implements Filter {
private static final Logger logger = Logger.getLogger(CacheControlFilter.class);
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse resp = (HttpServletResponse) response;
resp.setDateHeader("Expires", 0);
resp.setHeader("Last-Modified", new Date().toString());
resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
resp.setHeader("Pragma", "no-cache");
resp.setHeader("X-Content-Type-Options", "nosniff");
resp.setHeader("X-Frame-Options", "DENY");
chain.doFilter(request, response);
}
有没有办法只在用户注销而不是每个请求时清除缓存?我想将我的静态文件(css文件,js文件)存储在缓存中,并仅在用户注销时将其清除
欢迎任何建议。
由于
答案 0 :(得分:0)
请将您的过滤器配置为/ logout url的web.xml,例如:
<filter>
<filter-name>CacheControlFilter</filter-name>
<filter-class><YOUR_PACKAGE>.CacheControlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CacheControlFilter</filter-name>
<url-pattern>/logout</url-pattern>
</filter-mapping>
如果没有使用web.xml,请看这个链接:
https://www.mkyong.com/spring-mvc/how-to-register-a-servlet-filter-in-spring-mvc/
答案 1 :(得分:0)
您可以通过初始化程序类注册缓存过滤器。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ^([\w-]+)$ category/news/$1 [L]
祝你好运