不缓存页面过滤器
来源:互联网 发布:互联网it服务 编辑:程序博客网 时间:2024/05/22 04:42
代码:
index.html
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>测试页面</title></head><body> <img alt="" src="img12.jpg" width="200px" height="200px"/></body></html>
NoCacheFilter.java
package com.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.annotation.WebFilter;import javax.servlet.http.HttpServletResponse;public class NoCacheFilter implements Filter { public NoCacheFilter() { // TODO Auto-generated constructor stub }public void destroy() {// TODO Auto-generated method stub}public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {// TODO Auto-generated method stubHttpServletResponse httpResponse=(HttpServletResponse)response;httpResponse.setDateHeader("Expires", -1);httpResponse.setHeader("Cache-Control", "no-cache");httpResponse.setHeader("Pragma", "no-cache");chain.doFilter(request, response);}public void init(FilterConfig fConfig) throws ServletException {// TODO Auto-generated method stub}}
截图:
总结:貌似看不出什么功能,但同时使用这三个响应头,起到了不缓存页面过滤的效果。
0 0
- 不缓存页面过滤器
- Browser 不缓存页面过滤器
- ASP不缓存页面
- 设置页面不缓存
- 设置页面不缓存
- 不缓存页面
- 页面不使用缓存
- 页面不缓存图片
- 不缓存页面
- 强制页面不缓存
- 页面局部不缓存
- 不缓存页面
- 浏览器不缓存页面
- 页面不缓存设置
- 设置不使用缓存的过滤器
- 使asp页面不缓存
- 设置浏览器不缓存页面
- 页面不缓存 for php
- Yii2.0 探究三 :用户登录机制
- 个人收藏的一些很有性价比的Github链接
- 自定义View实现导航栏与主面板交互效果
- NoSQL
- 我钟爱的数据结构大复习
- 不缓存页面过滤器
- 16道嵌入式C语言面试题(经典)
- RTP协议
- Python2.7学习
- 欧拉计划 43
- 函数:字符串逆序
- zabbix实战--Php-fpm监控详解
- MyBatis入门基础(一)
- Ubuntu Git Linux命令 LNMP 知识链接总结黄金收藏