<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<meta http-equiv="Cache-control" content="no-cache">,是不存儲網(wǎng)頁。一般訪問會(huì)暫時(shí)存儲網(wǎng)頁下次訪問就快。但是對于頻繁更新的網(wǎng)站就不要存儲,所以用no-cache
另:
1。在
Asp頁面首部<head>加入
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache"
2。在HtML代碼中加入
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>
3。在重新調(diào)用原頁面的時(shí)候在給頁面?zhèn)饕粋€(gè)參數(shù)
Href="****.asp?
random()"
前兩個(gè)方法據(jù)說有時(shí)會(huì)失效,而第三種則是在跳轉(zhuǎn)時(shí)傳一個(gè)隨機(jī)的參數(shù)! 因?yàn)閍spx的緩存是與參數(shù)相關(guān)的,如果參數(shù)不同就不會(huì)使用緩存,而會(huì)重新生成頁面,每次都傳一個(gè)隨機(jī)的參數(shù)就可以避免使用緩存。這個(gè)僅適用于asp&asp.net
asp的隨機(jī)數(shù)函數(shù):
Function rndNum (strLong)
Dim temNum
Randomize
Do While Len(RndNum) < strLong
temNum=CStr(Chr((57-48)*rnd+48))
RndNum=RndNum&temNum
loop
End Function
參數(shù)為需要的隨機(jī)數(shù)長度*2
4。在jsp頁面中可使用如下代碼實(shí)現(xiàn)無緩存:
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
這些代碼加在<head> </head>中間具體如下
<head>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
</head>
5。window.location.replace("WebForm1.aspx");
參數(shù)就是你要覆蓋的頁面,replace的原理就是用當(dāng)前頁面替換掉replace參數(shù)指定的頁面。
這樣可以防止用戶點(diǎn)擊back鍵。使用的是javascript腳本,舉例如下:
a.html
<html>
<head>
<title>a</title>
<script language="javascript">
function jump(){
window.location.replace("b.html");
}
</script>
</head>
<body>
<a href="javascript:jump()">b</a>
</body>
</html>
b.html
<html>
<head>
<title>b</title>
<script language="javascript">
function jump(){
window.location.replace("a.html");
}
</script>
</head>
<body>
<a href="javascript:jump()">a</a>
</body>
</html>
前4種只是清空了cache,即存儲在Temporary Internet Files文件夾中的臨時(shí)文件,而第五種則是使用跳轉(zhuǎn)頁面文件替換當(dāng)前頁面文件,并沒有清空cache,也就是說Temporary Internet Files產(chǎn)生了相關(guān)的臨時(shí)文件,兩者搭配使用真是清空緩存,必備良藥。正好我這里有了記錄,所以常來看看哦。