当前位置: 代码迷 >> Web前端 >> 设立浏览器不缓存
  详细解决方案

设立浏览器不缓存

热度:127   发布时间:2013-10-01 12:15:56.0
设置浏览器不缓存
为了指示IE浏览器(客户端)不要缓存页面,服务器端的程序可以编写如下:response.setHeader(“Cache-Control”, “no-cache”);
response.setHeader(“Pragma”, “no-cache”);作用相当于上行代码,通常两者合用

public static void setNoCache(HttpServletRequest request, HttpServletResponse response){
if (request.getProtocol().compareTo("HTTP/1.0") == 0){

response.setHeader("Pragma","no-cache");

}else if (request.getProtocol().compareTo("HTTP/1.1") == 0){

response.setHeader("Cache-Control","no-cache");

}
response.setDateHeader("Expires",0);
}
  相关解决方案