设置ASP.NET页面不被缓存
/// <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来控制缓存的,这样就解决了
下一篇: C语言实现 求10 个整数中最大值