Is there any way to have multiple cache pages when i am using custom caching (VarByCustom)?
For an instance if i implement a caching custom variable browser vise , i would implement function in global as below
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == Request.Browser.Version)
{
return Request.Browser.Version;
}
else
{
return base.GetVaryByCustomString(context, custom);
}
}
Inside controller
[PartialCaching(500000)]
public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
this.CachePolicy.Duration = new TimeSpan(0,5,0);
this.CachePolicy.Cached = true;
this.CachePolicy.SetVaryByCustom(Request.Browser.Version);
lblDate.Text = DateTime.Now.ToShortDateString();
lblTime.Text = DateTime.Now.ToLongTimeString();
}
}
In this case I want to have multiple cache page on following scenario ;
- Open page on Firefox ~ Page is cached and return to the browser
- Open same page on same Firefox browser ~ cached page is sent as response
- Open same page on Chrome ~ Page is cached and return to the browser since browser is different.
Open same page on Chrome browser ~ cached page is sent as response
Open same page on Firefox again ~ Since page is cached for Chrome, this will identify as a change and it will cache again for Firefox, but in this case i want have cached page for Firefox in step one instead of caching again.