Abort OutputCache duration programmatically in asp.net mvc

I use the OutputCache attribute to cache the html output of my server-side actions.

Ok, this works, but now I have a situation where the content rarely changes, but when this happens, it is important for the user to see new data on the next request.

So, is there a way to programmatically interrupt the duration of the page cache?

+4
c # caching model-view-controller asp.net-mvc outputcache
Jul 29 '09 at 14:21
source share
3 answers

Yes, you can use the HttpResponse.RemoveOutputCacheItem Method . Check out this question:

  • SO - How to programmatically flush output cache for controller action method
+7
Jul 29 '09 at 18:10
source share
β€” -

You can extend OutputCacheAttribute to create your own caching mechanism, which allows you to use a dependency similar to the original ASP.net caching.

0
Jul 29 '09 at 14:52
source share

You can also use HttpCachePolicy.AddValidationCallback () . The general idea is that when a page is displayed and inserted into the cache, this callback is inserted along with the page. When a page is retrieved from the cache, the callback is called and makes a final determination of whether the cached page is obsolete (and should be loaded) or valid (and should be served). See AuthorizeAttribute source for an example. If the page becomes obsolete, in fact rarely, you can be better served by the RemoveOutputCacheItem () method, as indicated in another answer.

0
Jul 29 '09 at 21:13
source share



All Articles