HttpRequestCachePolicy 클래스

정의

HttpWebRequest 개체를 사용하여 가져온 리소스에 대한 애플리케이션의 캐싱 요구 사항을 정의합니다.

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
상속
HttpRequestCachePolicy

예제

다음 코드 예제에서는 애플리케이션 도메인에 대 한 기본 캐시 정책을 만들고 요청에 대 한 재정의 합니다.

// 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;
}

설명

사용 하 여 애플리케이션에 대 한 기본 캐시 정책을 지정할 수 있습니다는 DefaultCachePolicy 속성 또는 애플리케이션 또는 컴퓨터 구성 파일입니다. 자세한 내용은 <requestCaching> 요소(네트워크 설정)를 참조하세요.

속성을 사용하여 CachePolicy 개별 요청에 대한 캐시 정책을 지정할 수 있습니다.

웹 서비스에 대한 캐싱은 지원되지 않습니다.

생성자

HttpRequestCachePolicy()

HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

HttpRequestCachePolicy(DateTime)

지정된 캐시 동기화 날짜를 사용하여 HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan)

지정된 보관 기간 제어 및 시간 값을 사용하여 HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan)

지정된 최대 보관 기간, 보관 기간 제어 및 시간 값을 사용하여 HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime)

지정된 최대 보관 기간, 보관 기간 제어 값, 시간 값 및 캐시 동기화 날짜를 사용하여 HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

HttpRequestCachePolicy(HttpRequestCacheLevel)

지정된 캐시 정책을 사용하여 HttpRequestCachePolicy 클래스의 새 인스턴스를 초기화합니다.

속성

CacheSyncDate

이 인스턴스의 캐시 동기화 날짜를 가져옵니다.

Level

이 인스턴스가 만들어질 때 지정된 HttpRequestCacheLevel 값을 가져옵니다.

MaxAge

캐시에서 반환되는 리소스에 허용되는 최대 보관 기간을 가져옵니다.

MaxStale

캐시에서 반환되는 리소스에 허용되는 만료 후 최대 시간 값을 가져옵니다.

MinFresh

캐시에서 반환되는 리소스에 허용되는 만료 전 최소 시간을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

이 인스턴스의 문자열 표현을 반환합니다.

적용 대상

추가 정보