Share via


HttpRequestCachePolicy Sınıf

Tanım

Bir uygulamanın nesneler kullanılarak HttpWebRequest elde edilen kaynaklar için önbelleğe alma gereksinimlerini tanımlar.

public ref class HttpRequestCachePolicy : System::Net::Cache::RequestCachePolicy
public class HttpRequestCachePolicy : System.Net.Cache.RequestCachePolicy
type HttpRequestCachePolicy = class
    inherit RequestCachePolicy
Public Class HttpRequestCachePolicy
Inherits RequestCachePolicy
Devralma
HttpRequestCachePolicy

Örnekler

Aşağıdaki kod örneği, uygulama etki alanı için varsayılan bir önbellek ilkesi oluşturur ve bunu istek için geçersiz kılar.

// The following method demonstrates overriding the
// caching policy for a request.
static WebResponse^ GetResponseNoCache( Uri^ uri )
{
   // Set a default policy level for the "http:" and "https" schemes.
   HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default );
   HttpWebRequest::DefaultCachePolicy = policy;

   // Create the request.
   WebRequest^ request = WebRequest::Create( uri );

   // Define a cache policy for this request only. 
   HttpRequestCachePolicy^ noCachePolicy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::NoCacheNoStore );
   request->CachePolicy = noCachePolicy;
   WebResponse^ response = request->GetResponse();
   Console::WriteLine( L"IsFromCache? {0}", response->IsFromCache );
   
   return response;
}
// The following method demonstrates overriding the
// caching policy for a request.
public static WebResponse GetResponseNoCache(Uri uri)
{
    // Set a default policy level for the "http:" and "https" schemes.
    HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
    HttpWebRequest.DefaultCachePolicy = policy;
    // Create the request.
    WebRequest request = WebRequest.Create(uri);
    // Define a cache policy for this request only.
    HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
    request.CachePolicy = noCachePolicy;
    WebResponse response = request.GetResponse();
    Console.WriteLine("IsFromCache? {0}", response.IsFromCache);
    return response;
}

Açıklamalar

özelliğini veya uygulama ya da makine yapılandırma dosyalarını kullanarak DefaultCachePolicy uygulamanız için varsayılan bir önbellek ilkesi belirtebilirsiniz. Daha fazla bilgi için bkz <. requestCaching> Öğesi (Ağ Ayarları).

özelliğini kullanarak CachePolicy tek bir istek için önbellek ilkesini belirtebilirsiniz.

Web hizmetleri için önbelleğe alma desteklenmez.

Oluşturucular

HttpRequestCachePolicy()

HttpRequestCachePolicy sınıfının yeni bir örneğini başlatır.

HttpRequestCachePolicy(DateTime)

Belirtilen önbellek eşitleme tarihini kullanarak sınıfının yeni bir örneğini HttpRequestCachePolicy başlatır.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan)

Belirtilen yaş denetimi ve zaman değerlerini kullanarak sınıfının yeni bir örneğini HttpRequestCachePolicy başlatır.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan)

Belirtilen en büyük yaş, yaş denetimi değeri ve saat değerini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime)

Belirtilen yaş üst sınırını, yaş denetimi değerini, saat değerini ve önbellek eşitleme tarihini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır.

HttpRequestCachePolicy(HttpRequestCacheLevel)

Belirtilen önbellek ilkesini kullanarak sınıfının yeni bir örneğini HttpRequestCachePolicy başlatır.

Özellikler

CacheSyncDate

Bu örnek için önbellek eşitleme tarihini alır.

Level

HttpRequestCacheLevel Bu örnek oluşturulduğunda belirtilen değeri alır.

MaxAge

Önbellekten döndürülen bir kaynak için izin verilen en büyük yaşı alır.

MaxStale

Önbellekten döndürülen bir kaynak için izin verilen en yüksek eskime değerini alır.

MinFresh

Önbellekten döndürülen bir kaynak için izin verilen en düşük güncelliği alır.

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Bu örneğin dize gösterimini döndürür.

Şunlara uygulanır

Ayrıca bkz.