手动清除ASP。一个应用程序/web站点的NET服务器缓存?

时间:2021-10-19 03:50:17

How can I manually clear ASP.NET server cache (IIS 7) on a given application/website, like what can be done in IE to clear browser cache for a given domain?

如何手动清除ASP。NET服务器缓存(IIS 7)在给定的应用程序/网站上,就像IE中清除给定域的浏览器缓存所能做的那样?

2 个解决方案

#1


41  

Use the following to remove all objects from the cache

使用以下方法从缓存中删除所有对象。

IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

while (enumerator.MoveNext())
{

    HttpContext.Current.Cache.Remove((string)enumerator.Key);

}

Also, it is a bit of a sledgehammer option but you can restart the entire application as follows:

此外,这是一个大锤选项,但您可以重新启动整个应用程序如下:

System.Web.HttpRuntime.UnloadAppDomain();

#2


12  

I had the same problem, and recycling the application pool helped me. All my caches immediately reloaded as I wanted.

我遇到了同样的问题,回收应用程序池对我有帮助。我所有的缓存立即按我的要求重新加载。

#1


41  

Use the following to remove all objects from the cache

使用以下方法从缓存中删除所有对象。

IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

while (enumerator.MoveNext())
{

    HttpContext.Current.Cache.Remove((string)enumerator.Key);

}

Also, it is a bit of a sledgehammer option but you can restart the entire application as follows:

此外,这是一个大锤选项,但您可以重新启动整个应用程序如下:

System.Web.HttpRuntime.UnloadAppDomain();

#2


12  

I had the same problem, and recycling the application pool helped me. All my caches immediately reloaded as I wanted.

我遇到了同样的问题,回收应用程序池对我有帮助。我所有的缓存立即按我的要求重新加载。