System.Web Namespace HttpCachePolicy Class
Gets the list of all HTTP headers that will be used to vary cache output.
[ VB ]
Public ReadOnly Property VaryByHeaders As HttpCacheVaryByHeaders
[ C# ]
public HttpCacheVaryByHeaders VaryByHeaders {get;}
[ C++ ]
public: __property HttpCacheVaryByHeaders* get_VaryByHeaders ( );
[ JScript ]
public function get VaryByHeaders ( ) : HttpCacheVaryByHeaders;
An HttpCacheVaryByHeaders that specifies which HTTP headers are used to select the cached response.
When a cached item has several vary headers, a separate version of the requested document is available from the cache for each HTTP header type.
The following shows how to cache multiple versions of page output programmatically, based on an HTTP header value.
- In the page's code-declaration block or code-behind class, set the expiration and visibility policies for the cached page content using the HttpCachePolicy.SetExpires and HttpCachePolicy.SetCacheability methods, respectively.
- In the same code, specify the header name as the argument for the VaryByHeaders property, and set the property to true.
Response.Cache.VaryByHeaders[ "whatever" ] = true;
Response.Cache.VaryByHeaders ( "whatever" ) = true |
|
C# |
VB |
NOTE: If you need to vary the output cache by multiple header values, set the VaryByHeaders argument to a semi-colon delimited list of valid HTTP header names. If you need to vary the pages in the cache by all HTTP header names, use the VaryByUnspecifiedParameters method.
HttpCachePolicy Members Caching Multiple Versions of a Page