ajax请求或者页面需要缓存,代码如下

缓存页面代码

1 1 private void setClientCache(HttpServletResponse response, int maxAgeSec)
2 2     {
3 3         long maxAgeMill = maxAgeSec * 1000L;
4 4         Date now = new Date();
5 5         response.setHeader("Cache-Control", "max-age=" + maxAgeSec);
6 6         response.addDateHeader("Last-Modified", now.getTime());
7 7         response.addDateHeader("Expires", now.getTime() + maxAgeMill);
8 8     }

 

posted @ 2015-11-13 14:53  萝卜兔子  阅读(262)  评论(0编辑  收藏  举报