In Menus_ascx we see a cached custom string "authenticated"
<%@ OutputCache duration= "86400" varybyparam= "None" varybycustom= "authenticated"%>
Note: @OutputCache directives are included with the required Duration and VaryByParam attributes. The Duration property must be set to any integer greater than 0. If you do not want to use the functionality provided by the VaryByParam property, set its value to None
Overriding the GetVaryByCustomString method in the Global.asax file
This is where the user control is cached based on whether the user validates it, that is, a validated user control, an unauthenticated user control
1public override String GetVaryByCustomString (HttpContext context, string custom)
2 {
3//There are two dif Ferent possible caching cases here, we return a different string in each one.
4 if (context. request.isauthenticated)
5 {
6//Request is authenticated
7 return "B";
8}
9 Else
{One
/Request is not authenticated the return
"C";
}
14}
Based on this idea, we can develop an example of caching pages that vary by browser type.
For example, our existing page is webform3.aspx, we can do page caching according to the type of browser we visit.
First add in the page
<%@ OutputCache duration= "varybyparam=" "None" varybycustom= "Ietype"%>