Try our conversational search powered by Generative AI!

Output cache on child actions

Vote:
 

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 http://bergdaniel.se/asp-net-mvc-4-output-cache-with-episerver-7-preview ) 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?

Thanks

 

Jon

#70444
Apr 19, 2013 15:14
Vote:
 

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.

#70445
Apr 19, 2013 15:25
Vote:
 

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 : http://mvcdonutcaching.codeplex.com/

and implement my own custom provider

Thanks

#70454
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.