Episerver Output Cache - implementing











up vote
0
down vote

favorite












I am trying to follow some instructions I found online in order to implement output caching for episerver.



In my web.config I have set up the following:



   <caching>
<outputCache enableOutputCache="true">
</outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ClientResourceCache" enabled="true" duration="3600" varyByParam="*" varyByContentEncoding="gzip;deflate" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>


As a test, I selected StartPageController.cs and added the [ContentOutputCache] tag like so:



    [ContentOutputCache]
public class StartPageController : PageControllerBase<StartPage>
{
public ActionResult Index(StartPage currentPage)
{
var model = PageViewModel.Create(currentPage);

if (SiteDefinition.Current.StartPage.CompareToIgnoreWorkID(currentPage.ContentLink))
{

var editHints = ViewData.GetEditHints<PageViewModel<StartPage>, StartPage>();
editHints.AddConnection(m => m.Layout.Logotype, p => p.SiteLogotype);
editHints.AddConnection(m => m.Layout.Footer, p => p.FooterBlock);
}

return View(model);
}
}
}


Then the instructions say:




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);
}




Due to my limited knowledge of .NET, MVC etc.. this part confuses me as I am not sure in which file to place it and where? Does this go in StartPageController.cs? Or somewhere else?



Any pointers would be appreciated.



The instructions I am trying to follow are here.










share|improve this question






















  • That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
    – Ted Nyberg
    yesterday












  • As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
    – PartisanEntity
    yesterday

















up vote
0
down vote

favorite












I am trying to follow some instructions I found online in order to implement output caching for episerver.



In my web.config I have set up the following:



   <caching>
<outputCache enableOutputCache="true">
</outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ClientResourceCache" enabled="true" duration="3600" varyByParam="*" varyByContentEncoding="gzip;deflate" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>


As a test, I selected StartPageController.cs and added the [ContentOutputCache] tag like so:



    [ContentOutputCache]
public class StartPageController : PageControllerBase<StartPage>
{
public ActionResult Index(StartPage currentPage)
{
var model = PageViewModel.Create(currentPage);

if (SiteDefinition.Current.StartPage.CompareToIgnoreWorkID(currentPage.ContentLink))
{

var editHints = ViewData.GetEditHints<PageViewModel<StartPage>, StartPage>();
editHints.AddConnection(m => m.Layout.Logotype, p => p.SiteLogotype);
editHints.AddConnection(m => m.Layout.Footer, p => p.FooterBlock);
}

return View(model);
}
}
}


Then the instructions say:




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);
}




Due to my limited knowledge of .NET, MVC etc.. this part confuses me as I am not sure in which file to place it and where? Does this go in StartPageController.cs? Or somewhere else?



Any pointers would be appreciated.



The instructions I am trying to follow are here.










share|improve this question






















  • That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
    – Ted Nyberg
    yesterday












  • As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
    – PartisanEntity
    yesterday















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to follow some instructions I found online in order to implement output caching for episerver.



In my web.config I have set up the following:



   <caching>
<outputCache enableOutputCache="true">
</outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ClientResourceCache" enabled="true" duration="3600" varyByParam="*" varyByContentEncoding="gzip;deflate" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>


As a test, I selected StartPageController.cs and added the [ContentOutputCache] tag like so:



    [ContentOutputCache]
public class StartPageController : PageControllerBase<StartPage>
{
public ActionResult Index(StartPage currentPage)
{
var model = PageViewModel.Create(currentPage);

if (SiteDefinition.Current.StartPage.CompareToIgnoreWorkID(currentPage.ContentLink))
{

var editHints = ViewData.GetEditHints<PageViewModel<StartPage>, StartPage>();
editHints.AddConnection(m => m.Layout.Logotype, p => p.SiteLogotype);
editHints.AddConnection(m => m.Layout.Footer, p => p.FooterBlock);
}

return View(model);
}
}
}


Then the instructions say:




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);
}




Due to my limited knowledge of .NET, MVC etc.. this part confuses me as I am not sure in which file to place it and where? Does this go in StartPageController.cs? Or somewhere else?



Any pointers would be appreciated.



The instructions I am trying to follow are here.










share|improve this question













I am trying to follow some instructions I found online in order to implement output caching for episerver.



In my web.config I have set up the following:



   <caching>
<outputCache enableOutputCache="true">
</outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ClientResourceCache" enabled="true" duration="3600" varyByParam="*" varyByContentEncoding="gzip;deflate" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>


As a test, I selected StartPageController.cs and added the [ContentOutputCache] tag like so:



    [ContentOutputCache]
public class StartPageController : PageControllerBase<StartPage>
{
public ActionResult Index(StartPage currentPage)
{
var model = PageViewModel.Create(currentPage);

if (SiteDefinition.Current.StartPage.CompareToIgnoreWorkID(currentPage.ContentLink))
{

var editHints = ViewData.GetEditHints<PageViewModel<StartPage>, StartPage>();
editHints.AddConnection(m => m.Layout.Logotype, p => p.SiteLogotype);
editHints.AddConnection(m => m.Layout.Footer, p => p.FooterBlock);
}

return View(model);
}
}
}


Then the instructions say:




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);
}




Due to my limited knowledge of .NET, MVC etc.. this part confuses me as I am not sure in which file to place it and where? Does this go in StartPageController.cs? Or somewhere else?



Any pointers would be appreciated.



The instructions I am trying to follow are here.







asp.net-mvc outputcache episerver






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









PartisanEntity

1953823




1953823












  • That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
    – Ted Nyberg
    yesterday












  • As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
    – PartisanEntity
    yesterday




















  • That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
    – Ted Nyberg
    yesterday












  • As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
    – PartisanEntity
    yesterday


















That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
– Ted Nyberg
yesterday






That last part shouldn't be necessary. Have you checked if it works without it? Note that you shouldn't be logged in, as the output cache will be disabled for logged-in users. Also, check the cache settings attributes of the <applicationSettings> element in web.config.
– Ted Nyberg
yesterday














As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
– PartisanEntity
yesterday






As far as I can tell it is not working. When I check the headers in the browser then cache-control is set to private. Here is the entry from web.config: <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" />
– PartisanEntity
yesterday



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409124%2fepiserver-output-cache-implementing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409124%2fepiserver-output-cache-implementing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Futebolista

Jornalista