asp.net.ph

HttpCachePolicy.VaryByHeaders Property

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;

Property Value

An HttpCacheVaryByHeaders that specifies which HTTP headers are used to select the cached response.

Remarks

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.

Example

The following shows how to cache multiple versions of page output programmatically, based on an HTTP header value.

  1. 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.
  2. 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;
  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.

See Also

HttpCachePolicy Members   Caching Multiple Versions of a Page Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph