Is there a way to enable Sitecore caching for a ControllerRendering declared statically in a layout? In Webforms you could declare a rendering's caching settings like this:
<sc:Sublayout ID="slMyControl" path="~/path/to/my/control.ascx" VaryByParm="true" Cachable="true" runat="server" />
However, when I use the Html helper there is no overload on the Controller method to accept caching parameters?
@Html.Sitecore().Controller("NAMESPACE", "ACTION")
I'm running Sitecore 7.2
If you want statically bind a controller rendering, you should use the Rendering()
method on the html helper. There you can define the caching with parameters:
@Html.Sitecore().Rendering("<your rendering definition item id>", new { Cacheable = true, CacheKey = "my_rendering", Cache_VaryByData = true })
The parameters should have the same name as used in the sublayout, with a Cache_
prefix.