Valid for Sitecore
5.3.1
Layout caching in Sitecore
Q:
How can I cache layouts in Sitecore?
A:
Layouts in Sitecore can be cached in the following way:
- Turn off browser cache disabler: <setting name="DisableBrowserCaching" value="false"/>
- Add "<%@ OutputCache Duration="100" VaryByParam="none" VaryByCustom="itempath" %>" to your layout source.
- Add the following code to global.asax:
public override string GetVaryByCustomString(System.Web.HttpContext context, string arg)
{
string result = string.Empty;
if ((Sitecore.Context.Item != null) && (arg == "itempath"))
{
result = "_#itempath:" + Sitecore.Context.Item.Paths.Path.ToString();
}
else
{
result = base.GetVaryByCustomString(context, arg);
}
return result;
}
- Comment out the SaveFormAction processor in the web.config file:
<!-- <processor type="Sitecore.Pipelines.HttpRequest.SaveFormAction, Sitecore.Kernel"/> -->
Please note that this setting is already commented out in Sitecore 5.3.1. Build 070417.