OutputCache Implementation Help


Hi there,

Trying to set up outputcache but failing so far.

I have ensured that I have the following in my web.config:

    <outputcache enableoutputcache="true"/>
            <add name="ClientResourceCache" enabled="true" duration="3600" varybyparam="*" varybycontentencoding="gzip;deflate" />


<applicationsettings httpcacheability="Public" pagevalidatetemplate="false" uishowglobalizationuserinterface="true" uiurl="~/EPiServer/CMS/" urlrebasekind="ToRootRelative" uieditorcsspaths="~/Static/css/Editor.css" uisafehtmltags="b,i,u,br,em,strong,p,a,img,ol,ul,li">

Next, I added [ContentOutputCache] to my StartPageController.cs like so:

public class StartPageController : PageControllerBase
public ActionResult Index(StartPage currentPage)


var model = PageViewModel.Create(currentPage);

if (SiteDefinition.Current.StartPage.CompareToIgnoreWorkID(currentPage.ContentLink)) // Check if it is the StartPage or just a page of the StartPage type.
//Connect the view models logotype property to the start page's to make it editable
var editHints = ViewData.GetEditHints, StartPage>();
editHints.AddConnection(m => m.Layout.Logotype, p => p.SiteLogotype);
editHints.AddConnection(m => m.Layout.Footer, p => p.FooterBlock);

return View(model);

But it does not appear to be working. I have ensured that I am not logged in during testing. But when looking at the headers in the browser I see under cache-control: private.

In the article it mentions:

The next part of the process is to enable the response headers on your page.  If you don't do this you will see a no-cache set in your HTML requests response header.  To do this is pretty simple.  At some point on a page load you need to add the following code:

public void SetResposneHeaders()

But I am unsure where to place this bit, and how to call it.

Nov 22, 2018 12:29

You could add it to the controller you use the attribute on.

I would use the settings from Episerver though, for the values:

Nov 22, 2018 14:00

Hi thanks for this. I notice that max-age is 0 in the browsers headers.

Are these settings taken from the web.config file? If yes, I do not see anything in the web.config file called HttpCacheExpiration ?

Or is max-age=0 correct ??

Edited, Nov 22, 2018 14:41

The settings are taken from the applicationsettings in the Episerver node in the web.config. There you should set the httpCacheExpiration value

Nov 22, 2018 15:02

Thanks so much. I have added httpCacheExpiration="3600" to the web.config.

Interestingly when I check the headers in the browser I get max-age=31536000 which is 1 year if I am not mistaken. Is my value for httpCacheExpiration being misread, or is it supposed to be in ticks or something like that ? 

Nov 23, 2018 11:00

It's a timespan, so for an hour I think it would be 1:00:00

Nov 23, 2018 11:15


Nov 23, 2018 11:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.