您的位置:首页 > 编程语言 > ASP

ASP.NET 取消和禁用缓存

2014-03-20 10:49 162 查看
客户端取消:

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


服务器具端取消:

服务器端:

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来控制缓存的,这样就解决了

原文:http://ourstrade.blog.163.com/blog/static/123663391200972531115487/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: