The above are fine if you know what pages you want to clear the cache for. In my instance (ASP.NET MVC) I referenced the same data from all over. Therefore, when I did a [save] I wanted to clear cache site wide. This is what worked for me: http://aspalliance.com/668
यह एक OnActionExecuting फ़िल्टर के संदर्भ में किया जाता है। यह बेसकंट्रोलर या कुछ में OnActionExecuting को ओवरराइड करके आसानी से किया जा सकता है।
HttpContextBase httpContext = filterContext.HttpContext;
httpContext.Response.AddCacheItemDependency("Pages");
सेट अप:
protected void Application_Start()
{
HttpRuntime.Cache.Insert("Pages", DateTime.Now);
}
मामूली चिमटा:
मेरे पास एक सहायक है जो "फ़्लैश संदेश" जोड़ता है (त्रुटि संदेश, सफलता संदेश - "यह आइटम सफलतापूर्वक सहेजा गया है", आदि)। फ्लैश संदेश से बचने के लिए प्रत्येक आगामी जीईटी पर दिखने से बचने के लिए, मुझे फ़्लैश संदेश लिखने के बाद अमान्य करना पड़ा।
समाशोधन कैश:
HttpRuntime.Cache.Insert("Pages", DateTime.Now);
उम्मीद है की यह मदद करेगा।