引用自:http://hi.baidu.com/bdzdcjh/blog/item/47055cfcc9c3fbf9fc037f4d.html
網(wǎng)頁(yè)
緩存的作用是什么?應(yīng)該很重要。但是在開(kāi)發(fā)的時(shí)候,網(wǎng)頁(yè)緩存總是給我們一種莫名的煩惱。于是幾乎每一個(gè)開(kāi)發(fā)者都試圖解決過(guò)這個(gè)問(wèn)題。當(dāng)然,我也不是今天才著手解決這個(gè)問(wèn)題。但是今天一時(shí)心血來(lái)潮,寫(xiě)一篇,記錄一下用到的方法。
1.禁止客戶端緩存要在<head>中加入類似如下內(nèi)容(我當(dāng)然還沒(méi)有這么用過(guò)):
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
2.在動(dòng)態(tài)網(wǎng)頁(yè)中禁止緩存,要加入類似如下腳本
(1)(好久不用了):
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
%>
(2)jsp(我現(xiàn)在經(jīng)常用的):
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
posted on 2009-05-13 09:22 chenlh 閱讀(503) 評(píng)論(0) 編輯 收藏
網(wǎng)頁(yè)
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
2.在動(dòng)態(tài)網(wǎng)頁(yè)中禁止緩存,要加入類似如下
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
%>
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);