servlet中的缓存问题

HTTP常用响应头:(既能用于响应,也能用于请求)

Cache:no-cache

Pragma:no-cache

Connection:close/keep-Alive

Data:        

有时候我们会遇到这种情况,就是在不点刷新的时候,鼠标的光标停在地址栏时点击回车。

1.有些网站的及时性要求高,这就要求我们实时更新数据。

1 //制定该页面不缓存IE
2         response.setDateHeader("Expires", -1);
3         //为了保证兼容性
4         response.setHeader("Cache-Control", "no-cache");
5         response.setHeader("Pragma", "no-cache");


2.有些网站要求缓存一定的时间。

//制定该页面缓存时间
        response.setDateHeader("Expires", System.currentTimeMillis()+3600*1000*24

 

posted @ 2015-08-30 10:25  jorks  阅读(268)  评论(0编辑  收藏  举报