Hi there,
Trying to set up outputcache but failing so far.
I have ensured that I have the following in my web.config:
And:
Next, I added [ContentOutputCache] to my StartPageController.cs like so:
[ContentOutputCache]
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
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()
{
HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddMinutes(2.0));
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
HttpContext.Current.Response.Cache.SetValidUntilExpires(true);
}
But I am unsure where to place this bit, and how to call it.