Live Chat Icon For mobile
Live Chat Icon

Is it possible to cache a page by Browser Version and/or some params

Platform: ASP.NET| Category: Output Caching

Yes. In your page:

<%@ OutputCache Duration='60' VaryByParams='abc;xyz' VaryByCustom='browsermajorversion' %> 

In your global.asax file:


Public Overrides Function GetVaryByCustomString(context As HttpContext, custom As String) As String
	If custom.ToLower() = 'browsermajorversion' Then
		Dim browser As HttpBrowserCapabilities = context.Request.Browser
			Return browser.Browser + ' ' + browser.MajorVersion
		Return MyBase.GetVaryByCustomString(context, custom)
	End If
End Function ’GetVaryByCustomString


public override string GetVaryByCustomString(HttpContext context, string custom)
	if (custom.ToLower() == 'browsermajorversion') { 
		HttpBrowserCapabilities browser = context.Request.Browser; 
		return browser.Browser + ' ' + browser.MajorVersion; 
	return base.GetVaryByCustomString(context, custom); 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.