Export (0) Print
Expand All

HttpCacheVaryByParams Class

Provides a type-safe way to set the VaryByParams property.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public ref class HttpCacheVaryByParams sealed
public final class HttpCacheVaryByParams
public final class HttpCacheVaryByParams

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.

No code example is currently available or this language may not be supported.
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")){
   //...
}
 

System.Object
  System.Web.HttpCacheVaryByParams

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft