I have a Sitecore 7 Controller Rendering. I need to vary the OutputCache by a custom method.
The rendering is currently set to "Cachable", "VaryByData" and "VaryByParm" in Sitecore.
I've added an output cache attribute to my action, and set a custom vary string:
[OutputCache(VaryByCustom = "ThisIsATest", Duration = 60)]
public ActionResult Index()
{
...
}
My Global.asax inherits from Sitecore.Web.Application, and I've overridden GetVaryByCustomString as follows:
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "ThisIsATest")
return "some custom key";
return base.GetVaryByCustomString(context, custom);
}
I'm never seeing the GetVaryByCustomString method fire, and the controller is behaving as though it didn't have an OutputCache attribute on it at all... It's as though it's actually just doing the default "Cachable", "VaryByData", "VaryByParm" behaviour from Sitecore.
Any clues?