返回首页

asp.net中如何强制清除缓存

回答

评论会员:游客 时间:2012/02/07
codeprelang="cs"Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.Cache.SetNoStore();/pre/code把页面加载代码。现在会有浏览器高速缓存中没有数据,将尝试从SERV页:美高科技佩雷斯:我尝试,但它似乎没有工作NBSP的无效DisablePageCaching(){//用于禁用页面缓存HttpContext.Current.Response.Cache。SetExpires(DateTime.UtcNow.AddDays(-1))HttpContext.Current.Response.Cache.SetValidUntilExpires(假);NBSPHttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)HttpContext.Current.Response.Cache.SetNoStore()NBSPHttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1))}NBSP{BR}NBSP私人无效ClearCache(){NBSP条目的DictionaryEntry=默认(的DictionaryEntry)NBSP的foreach(在System.Web.HttpContext.Current.Cache的DictionaryEntryentry_loopVariable){{BR}NBSP条目=entry_loopVariable;System.Web.HttpContext.Current.Cache.Remove(entry.Key.ToString());NBSP}NBSPNBSP;(enumerator.IDictionaryEnumerator枚举HttpContext.Current.Cache.GetEnumerator()NBSP的MoveNext()){NBSP;HttpContext.Current.Cache.Remove(enumerator.Key.ToString())NBSP}HttpContext.Current.Response.ClearHeaders();BR}HttpContext.Current.Response.Expires=0;NBSPHttpContext.Current.Response.CacheControl="缓存";HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)HttpContext.Current。Response.Cache.SetNoStore()=TRUEHttpContext.Current.Response.Buffer;HttpContext.Current.Response.ExpiresAbsolute=DateTime.Now.Subtract(新的TimeSpan(1,0,0,0)){BR}HttpContext.Current.Response.AppendHeader("语用","无缓存")HttpContext.Current.Response.AppendHeader("","");{BR}HttpContext.Current.Response.AppendHeader"("缓存控制","无缓存");//的HTTP1.1HttpContext.Current.Response.AppendHeader("缓存控制","私人")//的HTTP1.1HttpContext.Current.Response.AppendHeader"("缓存控制","无店铺");/HTTP1.1的/HttpContext.Current.Response.AppendHeader"("缓存控制","必须重新验证")//HTTP1.1HttpContext.Current.Response.AppendHeader("缓存控制","最大陈旧=0");//HTTP1.1HttpContext.Current.Response.AppendHeader("缓存控制","张贴检查=0");//HTTP1.1HttpContext.Current.Response.AppendHeader("缓存控制","前检查=0");//HTTP1.1HttpContext.Current.Response。AppendHeader("语用","无缓存");//HTTP1.1HttpContext.Current.Response。AppendHeader("保持活动","超时=3,最大值=993");//HTTP1.1nbsp的;}
devildx2050
评论会员:游客 时间:2012/02/07
!脚本类型="文本/javascript"GTLT-的功能reloadIt(){clocktime=新的日期()VARutchours=clocktime.getUTCHours()VARutcminutesclocktime.getUTCMinutes=()utcseconds=clocktime.getUTCSeconds()VARutcyear=clocktime.getUTCFullYear()utcmonth=clocktime.getUTCMonth()=clocktime.getUTCDateutcday()(utchoursLT;10){utchours="0"utchours}{utcminutes(utcminutesLT;10)="0"utcminutes}(utcsecondsLT;10){utcseconds="0"utcseconds}(utcmonthLT;10){utcmonth="0"utcmonth}(utcdayLT;10){utcday="0"utcday}utctime=utcyearutcmonthutcday;utctime"=utchours=utctime(isNew.match('#','X'))isNew=self.location.href{self.locationutcminutesutcseconds;替换(isNew'#'X)}}NBSP//-LT;/scriptgtNBSPLT;/headgtLT;身体的onLoad="reloadIt"GT;
Morgs摩根
评论会员:游客 时间:2012/02/07
尝试:设置缓存{C}2。使用缓存codeprelang="c#"spanclass="code-keyword"if/span(Cache[spanclass="code-string""/spanspanclass="code-string"username"/span]!=spanclass="code-keyword"null/span&&Cache[spanclass="code-string""/spanspanclass="code-string"password"/span]!=spanclass="code-keyword"null/span){spanclass="code-comment"///spanspanclass="code-comment"cacheisstillalive/spanspanclass="code-SDKkeyword"String/spanusername=Cache[spanclass="code-string""/spanspanclass="code-string"username"/span].ToString();spanclass="code-SDKkeyword"String/spanpassword=Cache[spanclass="code-string""/spanspanclass="code-string"password"/span].ToString();}spanclass="code-keyword"else/span{spanclass="code-comment"///spanspanclass="code-comment"showerror,cacheobjectsdonotexist!/span}/pre/code3。清除缓存{体C3}快乐编码,morgs:美高科技佩雷斯:|,喜Morgs基本上解决方案的工作,但它是不是我需要的我与母版页的主题有问题的所有文件。母版页,主题是动态创建的。在所有的WebKit浏览器,我有这个问题NBSP。清除缓存解决问题NBSP。@devildx20503你能解释一下你的代码吗?