The “Content output cache” is strangely enough a basically undocumented feature of Episerver CMS. It’s strange, because the content output cache can be a simple way to really speed up your site.
I will not go into details about how to set up Content output cache in this article. Instead I’ll show a way to let the Episerver editor control if output cache should be used or not.
UPDATE: See comments below.
I recently had a requirement that an Episerver editor should be able to turn off the outputcache for specific pages. By default the pages are using output cache, but if the editor adds a block/feature/personalization that doesn’t work together with output cache, then the editor can switch off output cache for that specific page.
To support this I created the “EditableContentOutputCacheAttribute”, which is a slightly modified version of Episervers own ContentOutputCacheAttribute:
The attribute is added to the controllers that should return cached pages:
Remember that you need to configure the cache in web.config.
<episerver> <applicationsettings httpcacheability="Server" httpcacheexpiration="1:0:00" <="" p=""></applicationsettings></episerver> ...
For this attribute to work you need the IDisableOutputCache interface. You add that interface to the page types where the editors should be able to switch off the output cache.
Now the editor can turn off the output cache for a specific page!
Will this affect performance?
As you might have noticed, the Episerver page data is fetched by using the url. That code-snippet will run for every page request.
I’ve done some simple load testing to see if this will affect performance compared to using the regular outputcache, It was hard to get a clear indication how much this affected performance, because the difference was so small.
I would say it has very little impact on performance.
at time of writing I was using Episerver CMS 18.104.22.168