HttpCacheVaryByParams Class
Assembly: System.Web (in system.web.dll)
The VaryByParams property identifies which HTTP Get or Post parameters ASP.NET uses to uniquely identify a variation of the response when there are multiple cached responses for a resource. This is useful when a response depends on a set of client inputs, such as headers or parameters.
The HttpCacheVaryByParams is not directly related to HTTP cache-control headers, but helps ensure that a client or proxy varies by the specified parameters. For more information about VaryByParams, see RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, available on the World Wide Web Consortium (W3C) Web site. See section 14, "Header Field Definitions", for complete details.
The following code example demonstrates how the HttpCacheVaryByParams object is accessed from the HttpCachePolicy object associated with an HttpResponse.
get_Response().get_Cache().SetExpires(DateTime.get_Now().
AddSeconds(60));
get_Response().get_Cache().SetCacheability(HttpCacheability.Public);
get_Response().get_Cache().SetValidUntilExpires(false);
get_Response().get_Cache().get_VaryByParams().
set_Item("Category", true);
if (get_Response().get_Cache().get_VaryByParams().
get_Item("Category")) {
//...
}
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)) Response.Cache.SetCacheability(HttpCacheability.Public) Response.Cache.SetValidUntilExpires(false) Response.Cache.VaryByParams("Category") = true if(Response.Cache.VaryByParams("Category")){ //... }
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.