1
votes

I have an existing ASP.NET web forms solution (on Sitecore, if it helps) where we're adding some caching, and need it to be safe with postback. We're using the outputcache directive with both pages (i.e. Sitecore layouts) and controls (sublayouts), and VaryByCustom.

In order to programmatically set caching parameters from within controls, we are investigating the use of the BasePartialCachingControl with ControlCachePolicy as detailed here: https://msdn.microsoft.com/en-us/library/system.web.ui.basepartialcachingcontrol(v=vs.100).aspx https://msdn.microsoft.com/en-us/library/system.web.ui.controlcachepolicy(v=vs.100).aspx

However, when the asp:BasePartialCachingControl tag is added to a control as a wrapper, we get the "Unknown server tag 'asp:BasePartialCachingControl'" parser error. Adding an import directive for the class's namespace does not help. How do we resolve this? Thank you.

1

1 Answers

0
votes

Sitecore provides you with output cache for user control out of the box,you can use Sitecore static binding for Sublayout, and map it to your user control, and there is a property there for cache, You can vary by several different criteria:

<sc:Sublayout ID="myControl" path="~/path/to/my/control.ascx" VaryByData="true" Cachable="true" runat="server" />

and if you are using dynamic binding from Sitecore go the the sublayout you can define caching from there as well under cache section :

enter image description here

If you want to vary cache by anothor parameter, checkout this link: https://briancaos.wordpress.com/2015/12/18/sitecore-sublayout-caching-vary-by-cookie/