ASP.NET清除缓存 [英] ASP.NET Clear Cache
本文介绍了ASP.NET清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果您缓存中的HttpHandler的页面以
_context.Response.Cache.SetCacheability(HttpCacheability.Public);
_context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(180));
,才有可能从缓存中清除特定的页面?
解决方案
是可以清除某一页
从Cache?
块引用>是:
的Htt presponse.RemoveOutputCacheItem(/页/ Default.aspx的);
您也可以使用缓存依赖于从缓存中删除网页:
this.Response.AddCacheItemDependency(钥匙);
作出这一呼吁,如果修改后
缓存[键]
,这将导致从缓存中删除的页面。在情况下,它可能会帮助,我盖在我的书中详细缓存:超快速ASP.NET 。
If you cache pages in a HttpHandler with
_context.Response.Cache.SetCacheability(HttpCacheability.Public); _context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(180));
is it possible to clear a certain page from the cache?
解决方案is it possible to Clear a certain page from the Cache?
Yes:
HttpResponse.RemoveOutputCacheItem("/pages/default.aspx");
You can also use Cache dependencies to remove pages from the Cache:
this.Response.AddCacheItemDependency("key");
After making that call, if you modify
Cache["key"]
, it will cause the page to be removed from the Cache.In case it might help, I cover caching in detail in my book: Ultra-Fast ASP.NET.
这篇关于ASP.NET清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文