I have a complex website that uses .NETs output caching enabled through Sitefinity. Recently we needed to have a specific user control have different cached versions depending on user location. So I gave the user control an OutputCache directive with VaryByCustom set and overrode the GetVaryByCustomString method in Global.asax to get the user location. The problem is that even in a simple test case this is not working. We tested this use case outside the context of Sitefinity to verify whether it was causing the issue by making a new project containing an .aspx page and placing a new .ascx user control inside of it. The page has a label that gets the current time on load as well as the control. The control also has a label that renders the current time. If I give the page OutputCache set to this:
<%@ OutputCache Duration="60" VaryByParam="none" %>
and the control set to this:
<%@ OutputCache Duration="60" VaryByParam="none" VaryByCustom="browser" %>
the expected functionality does not happen. The thinking was that if we opened this page in two different browsers we would see two different times in the second label. Am I completely missing something here? I am new to dealing with .NET caching so it is entirely possible.
Thanks
Here is my override of GetVaryByCustomString:
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "custom")
{
// return custom logic
}
else
{
return base.GetVaryByCustomString(context, custom);
}
}