小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

(轉(zhuǎn)載)禁止頁(yè)面緩存的方法

 _小女子_ 2013-12-24
1、在Asp頁(yè)面首部<head>加入

 

以下為引用的內(nèi)容:

  Response.Buffer = True   
  Response.ExpiresAbsolute = Now() - 1   
  Response.Expires = 0   
  Response.CacheControl = "no-cache"   
  Response.AddHeader "Pragma", "No-Cache" 

 

  2、在HtML代碼中加入

 

以下為引用的內(nèi)容:

  <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)用原頁(yè)面的時(shí)候在給頁(yè)面?zhèn)饕粋€(gè)參數(shù)   Href="****.asp?random()"   

  前兩個(gè)方法據(jù)說(shuō)有時(shí)會(huì)失效,而第三種則是在跳轉(zhuǎn)時(shí)傳一個(gè)隨機(jī)的參數(shù)! 因?yàn)閍spx的緩存是與參數(shù)相關(guān)的,如果參數(shù)不同就不會(huì)使用緩存,而會(huì)重新生成頁(yè)面,每次都傳一個(gè)隨機(jī)的參數(shù)就可以避免使用緩存。這個(gè)僅適用于asp&asp.net

 

  4、在jsp頁(yè)面中可使用如下代碼實(shí)現(xiàn)無(wú)緩存:

 

以下為引用的內(nèi)容:

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>中間具體如下

 

以下為引用的內(nèi)容:

<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ù)就是你要覆蓋的頁(yè)面,replace的原理就是用當(dāng)前頁(yè)面替換掉replace參數(shù)指定的頁(yè)面。這樣可以防止用戶點(diǎn)擊back鍵。使用的是javascript腳本,舉例如下:

 

以下為引用的內(nèi)容:

 

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> 

 

6、php

# 讓它在過(guò)去就“失效"
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

# 永遠(yuǎn)是改動(dòng)過(guò)的
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

# HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

# HTTP/1.0
header("Pragma: no-cache");

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多