System.Web.HttpCacheVaryByContentEncodings Class

Provides a type-safe way to set the HttpCachePolicy.VaryByContentEncodings property of the System.Web.HttpCachePolicy class.

See Also: HttpCacheVaryByContentEncodings Members

Syntax

public sealed class HttpCacheVaryByContentEncodings

Remarks

The HttpCachePolicy.VaryByContentEncodings property is used to specify whether dynamically compressed responses are cached. Caching dynamically compressed responses means that the cost of compression is incurred only one time, during the first request for the resource (or after an application restart) and when the cache item expires.

The HttpCachePolicy.VaryByContentEncodings property of the System.Web.HttpCachePolicy class identifies which request header parameters ASP.NET uses to uniquely identify a variation of the response if there are multiple cached responses for a resource. This is useful when a response depends on a set of client inputs, such as headers, parameters, or content encodings.

The System.Web.HttpCacheVaryByContentEncodings class is not directly related to HTTP cache-control headers. However, it helps make sure that a response to a client or a proxy varies by the specified content encoding. Setting the cache to vary by content encoding enables ASP.NET to vary the response by the Accept-Encoding header. When a request is processed, the Accept-Encoding header is checked and the first acceptable encoding is identified and used to take one of the following actions:

For more information about the HttpCachePolicy.VaryByContentEncodings property, see RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, available on the tp://go.microsoft.com/fwlink/?linkid=37125. See section 14, "Header Field Definitions", for complete details.

You can set the HttpCachePolicy.VaryByContentEncodings property by using the @ OutputCache directive or by adding a profile to the outputCacheProfile element in the Web.config file.

Requirements

Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0