HttpCachePolicy.SetCacheability Metod

Definition

Cache-Control Anger HTTP-huvudet. Cache-Control HTTP-huvudet styr hur dokument ska cachelagras i nätverket.

Överlagringar

Name Description
SetCacheability(HttpCacheability)

Cache-Control Anger rubriken till ett av värdena HttpCacheabilityför .

SetCacheability(HttpCacheability, String)

Cache-Control Anger huvudet till ett av värdena HttpCacheability för och lägger till ett tillägg till direktivet.

SetCacheability(HttpCacheability)

Cache-Control Anger rubriken till ett av värdena HttpCacheabilityför .

public:
 void SetCacheability(System::Web::HttpCacheability cacheability);
public void SetCacheability(System.Web.HttpCacheability cacheability);
member this.SetCacheability : System.Web.HttpCacheability -> unit
Public Sub SetCacheability (cacheability As HttpCacheability)

Parametrar

cacheability
HttpCacheability

Ett HttpCacheability uppräkningsvärde.

Undantag

cacheability är inte ett av uppräkningsvärdena.

Exempel

I följande kodexempel visas hur du anger Cache-Control rubriken till det uppräknade värdet för no-cache.

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetCacheability(HttpCacheability.NoCache)

Kommentarer

SetCacheability introduceras i .NET Framework version 3.5. Mer information finns i Versioner och beroenden.

Gäller för

SetCacheability(HttpCacheability, String)

Cache-Control Anger huvudet till ett av värdena HttpCacheability för och lägger till ett tillägg till direktivet.

public:
 void SetCacheability(System::Web::HttpCacheability cacheability, System::String ^ field);
public void SetCacheability(System.Web.HttpCacheability cacheability, string field);
member this.SetCacheability : System.Web.HttpCacheability * string -> unit
Public Sub SetCacheability (cacheability As HttpCacheability, field As String)

Parametrar

cacheability
HttpCacheability

Uppräkningsvärdet HttpCacheability som rubriken ska anges till.

field
String

Cachekontrolltillägget som ska läggas till i huvudet.

Undantag

field är null.

cacheability är inte Private eller NoCache.

Exempel

Följande kodexempel visar hur Cache-Control huvudet är inställt på uppräkningsvärdet private och lägger till ett cachekontrolltillägg. Det ändrade direktivet innebär att förutom alla icke-delade cacheminnen kan alla cacheminnen som endast delas av medlemmar i communityn med namnet "DEV" cachelagrat svaret.

Response.Cache.SetCacheability(HttpCacheability.Private, "Community=DEV");
Response.Cache.SetCacheability(HttpCacheability.Private, "Community=DEV")

Kommentarer

Fältnamnstillägget är endast giltigt när det används med direktiven private eller no-cache . Mer information finns i RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, tillgängligt på W3C-webbplatsen (World Wide Web Consortium).

Den här metoden utlöser ett ogiltigt argumentfel om inkompatibla direktiv och tillägg kombineras.

SetCacheability introduceras i .NET Framework version 3.5. Mer information finns i Versioner och beroenden.

Gäller för