Varying the Output Cache by Header

Another option is to use the VaryByHeader attribute to create different cached versions of a page when the value of a particular browser header changes. Several standard browser headers are transmitted with each page request, including

Accept-Language Represents a prioritized list of languages that represent the preferred human language of the user making the request.

User-Agent Represents the type of device making the request.

Cookie Represents the browser cookies created in the current domain.

For example, the page in Listing 29.5 includes an <%@ OutputCache %> directive that has a VaryByHeader attribute with the value User-Agent. When you request the page with different browsers, different versions ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.