asp.net.ph

HttpCachePolicy.VaryByParams Property

System.Web Namespace   HttpCachePolicy Class


Gets the list of parameters received by a GET ( querystring ) or POST ( in the body of the HTTP request ) that affect caching.

[ VB ]
Public ReadOnly Property VaryByParams As HttpCacheVaryByParams

[ C# ]
public HttpCacheVaryByParams VaryByParams {get;}

[ C++ ]
public: __property HttpCacheVaryByParams* get_VaryByParams ( );

[ JScript ]
public function get VaryByParams ( ) : HttpCacheVaryByParams;

Property Value

An HttpCacheVaryByParams that specifies which cache-control headers are used to select the cached response.

Remarks

For each named parameter in VaryByParams a separate version of the requested document is available from the cache, the version varying by the parameter's value.

Example

The following shows how to cache multiple versions of page output programmatically, based on query string or form POST parameters.

  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 parameter name as the argument for the VaryByParams property, and set the property to true.

Response.Cache.VaryByParams[ "whatever" ] = true;
  C# VB

NOTE: If you need to vary the output cache by multiple parameters, set the VaryByParams argument to a semi-colon delimited list of valid parameter names. If you need to vary the cache by all the parameter values, set the attribute to an asterisk *.

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