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;
An HttpCacheVaryByParams that specifies which cache-control headers are used to select the cached response.
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.
The following shows how to cache multiple versions of page output programmatically, based on query string or form POST parameters.
- 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 parameter name as the argument for the VaryByParams property, and set the property to true.
Response.Cache.VaryByParams[ "whatever" ] = 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 *.
HttpCachePolicy Members Caching Multiple Versions of a Page