It is important to note that if your VaryByCustom changes, asp.net stores a separate cached version of the page.
So, suppose your VaryByCustom is "custom1" with Duration = "60", then this will be cached for 60 seconds.
, VaryByCustom "custom2" = "60", asp.net , "custom1", 60 .
, VaryByCustom .
Global.asax
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "browser")
{
string browserName;
browserName = Context.Request.Browser.Browser;
browserName += Context.Request.Browser.MajorVersion.ToString();
return browserName;
}
else
{
return base.GetVaryByCustomString(context, custom);
}
}
Aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebFormsPlayGround._Default" %>
<%@ OutputCache Duration="40" VaryByParam="None" VaryByCustom="browser" %>
protected void Page_Load(object sender, EventArgs e)
{
lblTime.Text = "The time now is: <br/>";
lblTime.Text += DateTime.Now.ToString();
}
asp: aspx, , .