Try our conversational search powered by Generative AI!

Output cache on child actions


Hi all, I have been looking into output cacheing but am yet to find a conclusive article on how EPiServer caches, and wheather it overrides any of the built in cacheing.

I dont want to use [ContentOutputCache] on my controller Index() method because the site has a shopping basket and several other things that are not fixed for all users. I only want to cache child actions so that i can do partial cacheing - but if I place this method on a child action that contains my content to render, then it complains.

Obviously I cannot use the mvc output cache because it does not get invalidated when content changes. So i thought about rolling out my own OutputCacheProvider ( like ) but when i do that the Add and Set methods never get fired! I can see the get method is hit but always returns null.


Has anyone implemented a reliable output cache for child actions that refreshes with content updates (and varies by display channel)

Or can someone point me in the right direction? What is the best way to do this, and is episerver interfering with the standard output cacheing?




Apr 19, 2013 15:14

EPiServer extends the ordinary MVC output caching with a cachedependency so that when content is published the outout cache is evicted. The reason it is not possible to use the attribute on a child action is that ASP.NET MVC will not put the output cache for child actions in "ordinary" httpRuntime cache instead it will use an own in memory cache. Since the cache is not the same it is not possible to have a cache dependency and hence will the output cache not be evicted at publish of content.

The same problem will occur if you write your own output cache provider, that is that you will not be able to set a cache dependency so it gets evicted at publish of a content. You could probably do something like listening to ContentPublished and then evict everything from your provider.

Apr 19, 2013 15:25

Thanks Johan, that was the idea I had. a bit bulk force, but I was planning on using my own cache and picking up that publish event and then clearing all the episerver output cache items. However Add() and Set() just dont get called! Your'e right that its an MVC thing.

I'm going to use this :

and implement my own custom provider


Apr 19, 2013 17:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.