不缓存页面

 

 

.

HTML meta pragma no-cache 页面缓存

 

pragmano-cache用于定义页面缓存
pragma
出现在http-equiv属性中,使用content属性的no-cache值表示是否缓存网页
引用网址:http://www.dreamdu.com/xhtml/no-cache/
不缓存页面(为了提高速度一些浏览器会缓存浏览者浏览过的页面,通过下面的定义,浏览器一般不会缓存页面,而且浏览器无法脱机浏览.)

meta pragma no-cache示例
<meta http-equiv="pragma" content="no-cache" />

 

 

二.

 

    #region "设置不缓存网页"

    /// <summary>

    /// 设置不缓存网页

 

    /// </summary>

    public static void SetNoWebCache()

{

//停止当前相应的所有源服务器缓存

        HttpContext.Current.Response.Cache.SetNoServerCaching();

    HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

        HttpContext.Current.Response.Cache.SetNoStore();

//Expires http 标头设置为绝对日期和时间   

    HttpContext.Current.Response.Cache.SetExpires(new DateTime(1900, 01, 01, 00, 00, 00, 00));

    }

    #endregion

 

 

三.

不缓存页面

做删除主题模块时发现必须手动刷新,有什么办法可以实现不手动刷新,点击了提交,显示成功后就把数据库当中的结果显示在当前页面呢?
从同事那里得知有个方法可以实现,禁止Cache 
//
禁止Cache.  
        response.setHeader("Pragma","No-Cache");  
        response.setHeader("Cache-Control","No-Cache");  
        response.setDateHeader("Expires",   0);  
  %>


禁用客户端缓存  
  HTML  
          <META   HTTP-EQUIV="pragma"   CONTENT="no-cache">  
          <META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache,   must-revalidate">  
          <META   HTTP-EQUIV="expires"   CONTENT="Mon,   23   Jan   1978   12:52:30   GMT">  
  ASP  
  <%  
          Response.Expires   =   -1  
          Response.ExpiresAbsolute   =   Now()   -   1  
          Response.cachecontrol   =   "no-cache"  
  %>  
  PHP  
          header("Expires:   Mon,   26   Jul   1997   05:00:00   GMT");  
          header("Cache-Control:   no-cache,   must-revalidate");  
          header("Pragma:   no-cache");  
  JSP  
          response.setHeader("Pragma","No-Cache");  
          response.setHeader("Cache-Control","No-Cache");  
          response.setDateHeader("Expires",   0);  
  C#
中禁止cache的方法!  
          Response.Buffer=true;  
          Response.ExpiresAbsolute=System.DateTime.Now.AddSeconds(-1);  
          Response.Expires=0;  
          Response.CacheControl="no-cache";


IE后退按钮时让JSP不读缓存:(里面有相应解释,值的一看)
http://www.xrss.cn/Info/7185.Html

方法一:

1,使用Java提供的方法,在jsp或者servlet中都可以

2,使用HTML标记,如下面:。。。

方法二:

   IE中也可通过设置实现:把/工具/INTE.Net选项/常规/设置/的检察所存页面的较新版本,设为每次访问该页时都检查.

 

 

 

 

 

四.

设置ASP.NET页面不被缓存

2008-05-07 12:23

/// <summary>
         ///
设置页面不被缓存
         /// </summary>
         private void SetPageNoCache()
         {
             Response.Buffer = true;
             Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
             Response.Expires = 0;
             Response.CacheControl = "no-cache";
             Response.AppendHeader("Pragma", "No-Cache");
         }

1。 取消缓存


2)客户端取消

<html>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>

3)服务器端取消:

服务器端:
    Response.Buffer = true;
    Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
    Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
    Response.Expires = 0;
    Response.CacheControl = "no-cache";
    Response.Cache.SetNoStore();

Global里面:  
protected   void   Application_BeginRequest(Object   sender,   EventArgs   e)  
{  
        HttpContext.Current.Response.Cache.SetNoStore();  
}
<%@ OutPutCache Location="None"%>

页面基类:
public   class   PageBase   :   Page  
{  
      public   PageBase()   {}  

      protected   override   OnLoad(   EventArgs   e   )   {  
              Response.Cache.SetNoStore();  
              base.OnLoad();  
      }  
}  

最简单的办法 :-)
CSDN的这个论坛,在URL后面随机的加一些没用的参数,比如:
http://xxx/xxx/xxx.jpg?p=xxx

IE是用URL来控制缓存的,这样就解决了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值