Is it possible to clear the ASP.NET application Cache without resetting the AppDomain?
asp.net, caching
Solution
Short answer: No.
ASP.NET Cache doesn't have a administration interface to manage it. You'll need to recycle your application pool, or to to create a simple page to do Delete Items from the Cache in ASP.NET.
EDIT: Inspired on Mick answer, you could to have a page like this (`RemoveCache.aspx`):
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Request.QueryString["name"]))
{
foreach (DictionaryEntry item in Cache)
{
Cache.Remove(item.Key.ToString());
Response.Write(item.Key.ToString() + " removed<br />");
}
}
else
{
Cache.Remove(Request.QueryString["name"]);
}
}
</script>
If you call `RemoveCache.aspx` all your cache will be removed; running `RemoveCache.aspx?name=Products`, just `Products` cache entry will be removed.
Problem
I would like to reset/clear an item in the Cache, but without resetting the application or writing a specialized page just for this. ie, a non-programmatic solution. Is this possible?