I'm not sure about the differences between VaryByHeader="User-Agent"
and VaryByCustom="Browser"
. Is it right that the latter will create less cached pages? Or in other words, if I wish to cache only for different browser-types (and versions), the latter is the better choice?
Thx for any advice! sl3dg3
From the MSDN article - ASP.NET Caching: Techniques and Best Practices:
In order to enable separate cache entries for each browser, VaryByCustom can be set to a value of "browser". This functionality is built into the caching module, and will insert separate cached versions of the page for each browser name and major version.
I'd take this to mean that the following useragents would all be considered IE9.0, and create one cache entry:
But would create 3 entries if you used VaryByHeader="User-Agent"
The user agent can have more stuff than just the browser, like OS and even some plugins including .NET, so, browser by guessing should have less cached pages.
Also, this is what the best practices page recommend to use:
http://msdn.microsoft.com/en-us/library/aa478965.aspx
Also from this best practices article I can see that browser
DOES vary by browser versions. That was my only fear and it's good they already cover it!
In order to enable separate cache entries for each browser, VaryByCustom can be set to a value of "browser". This functionality is built into the caching module, and will insert separate cached versions of the page for each browser name and major version.
<%@ OutputCache Duration="60" VaryByParam="None" VaryByCustom="browser" %>
Note that even with user-agent you wouldn't have so many more copies of the pages, so, I'd argue it's not a big deal which one you puck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With