Possible Duplicate:
How to programmatically clear outputcache for controller action method
How to clear cache in specified controller?
I try to use several approaches:
Response.RemoveOutputCacheItem();
Response.Cache.SetExpires(DateTime.Now);
There is no any effect, it not work. :( May be exists any way to get all keys in controller cache and remove they explicitly? And in which overridden method i should perform clear cache? and how to do that?
Does any ideas?
In ASP.NET MVC, there is an OutputCache filter attribute that you can apply and this is the same concept as output caching in web forms. The output cache enables you to cache the content returned by a controller action. Output caching basically allows you to store the output of a particular controller in the memory.
There is a property of the OutputCache attribute 'Location' with following possible values: Any (Default): Content is cached in three locations: the web server, any proxy servers, and the web browser. Client: Content is cached on the web browser. Server: Content is cached on the web server.
Have you tried
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public ActionResult DontCacheMeIfYouCan()
{
}
If this doesn't do it for you then a custom attribute like Mark Yu suggests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With