次の方法で共有


HttpRequestCachePolicy コンストラクター

定義

HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
HttpRequestCachePolicy()

HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy(DateTime)

指定したキャッシュ同期日を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy(HttpRequestCacheLevel)

指定したキャッシュ ポリシーを使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan)

指定した年齢コントロールと時間値を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan)

指定した最大有効期間、年齢制御値、および時間値を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime)

指定した最大有効期間、年齢制御値、時刻値、キャッシュ同期日付を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

HttpRequestCachePolicy()

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy();
public HttpRequestCachePolicy();
Public Sub New ()

次のコード例は、このコンストラクターを使用してキャッシュ ポリシーを設定する方法を示しています。

public static WebResponse GetResponseUsingCacheDefault(Uri uri)
{
    // Set  the default cache policy level for the "http:" scheme.
    RequestCachePolicy policy = new RequestCachePolicy();
    // Create the request.
    WebRequest request = WebRequest.Create(uri);
    request.CachePolicy = policy;
    WebResponse response = request.GetResponse();
    Console.WriteLine("Policy level is {0}.", policy.Level.ToString());
    Console.WriteLine("Is the response from the cache? {0}", response.IsFromCache);

    return response;
}

注釈

このコンストラクターは、 Level プロパティを初期化して Defaultします。

適用対象

HttpRequestCachePolicy(DateTime)

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

指定したキャッシュ同期日を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy(DateTime cacheSyncDate);
public HttpRequestCachePolicy(DateTime cacheSyncDate);
new System.Net.Cache.HttpRequestCachePolicy : DateTime -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheSyncDate As DateTime)

パラメーター

cacheSyncDate
DateTime

キャッシュに格納されているリソースを再検証する必要がある時刻を指定する DateTime オブジェクト。

次のコード例は、キャッシュ同期日に基づいてキャッシュ ポリシーを作成する方法を示しています。

public static HttpRequestCachePolicy CreateLastSyncPolicy(DateTime when)
{
    HttpRequestCachePolicy policy =
       new HttpRequestCachePolicy(when);

    Console.WriteLine("When: {0}", when);
    Console.WriteLine(policy.CacheSyncDate.ToString());
    return policy;
}

注釈

キャッシュ同期日付を使用すると、キャッシュされたコンテンツを再検証する必要がある絶対日付を指定できます。 キャッシュエントリがキャッシュ同期日より前に最後に再検証された場合、サーバーとの再検証が行われます。 キャッシュ同期日以降にキャッシュ エントリが再検証され、キャッシュされたエントリを無効にするサーバーの再検証要件がない場合は、キャッシュからのエントリが使用されます。 キャッシュ同期の日付が将来の日付に設定されている場合、エントリは要求されるたびに、キャッシュ同期の日付が経過するまで再検証されます。

このコンストラクターは、 Level プロパティを初期化して Defaultします。 CacheSyncDate プロパティは、cacheSyncDateに初期化されます。

適用対象

HttpRequestCachePolicy(HttpRequestCacheLevel)

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

指定したキャッシュ ポリシーを使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy(System::Net::Cache::HttpRequestCacheLevel level);
public HttpRequestCachePolicy(System.Net.Cache.HttpRequestCacheLevel level);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpRequestCacheLevel -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (level As HttpRequestCacheLevel)

パラメーター

次のコード例では、キャッシュ内のリソースをキャッシュから使用できるようにするキャッシュ ポリシーを作成する方法を示します。

public static HttpRequestCachePolicy CreateCacheIfAvailablePolicy()
{
    HttpRequestCachePolicy policy =
        new HttpRequestCachePolicy(HttpRequestCacheLevel.CacheIfAvailable);

    Console.WriteLine(policy.ToString());
    return policy;
}

注釈

このコンストラクターは、 Level プロパティを初期化して levelします。

HttpRequestCacheLevel値は、キャッシュを有効にするかどうか、およびキャッシュを使用できるタイミングを制御します。 詳細については、 HttpRequestCacheLevel ドキュメントを参照してください。

適用対象

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan)

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

指定した年齢コントロールと時間値を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, ageOrFreshOrStale As TimeSpan)

パラメーター

cacheAgeControl
HttpCacheAgeControl

MaxAgeMaxStale、またはMinFreshのいずれかのHttpCacheAgeControl列挙値。

ageOrFreshOrStale
TimeSpan

時間を指定する TimeSpan 値。

例外

cacheAgeControl パラメーターに指定された値は、このコンストラクターでは使用できません。

次のコード例は、最小鮮度に基づいてキャッシュ ポリシーを作成する方法を示しています。

public static HttpRequestCachePolicy CreateMinFreshPolicy(TimeSpan span)
{
    HttpRequestCachePolicy policy =
        new HttpRequestCachePolicy(HttpCacheAgeControl.MinFresh, span);
    Console.WriteLine("Minimum freshness {0}", policy.MinFresh.ToString());
    return policy;
}

注釈

cacheAgeControl値は、ageOrFreshOrStale パラメーター値の意味を定義し、関連付けられたプロパティを設定するために使用されます。 たとえば、 MaxStaleを指定すると、 MaxStale プロパティは ageOrFreshOrStale パラメーターの値に設定されます。

このコンストラクターは、 Level プロパティを初期化して Defaultします。

適用対象

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan)

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

指定した最大有効期間、年齢制御値、および時間値を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan * TimeSpan -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, maxAge As TimeSpan, freshOrStale As TimeSpan)

パラメーター

cacheAgeControl
HttpCacheAgeControl

HttpCacheAgeControl価値。

maxAge
TimeSpan

リソースの最大有効期間を指定する TimeSpan 値。

freshOrStale
TimeSpan

時間を指定する TimeSpan 値。

例外

cacheAgeControl パラメーターに指定された値は無効です。

次のコード例では、最小鮮度と最大有効期間に基づいてキャッシュ ポリシーを作成する方法を示します。

public static HttpRequestCachePolicy CreateFreshAndAgePolicy(TimeSpan freshMinimum, TimeSpan ageMaximum)
{
    HttpRequestCachePolicy policy =
        new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, ageMaximum, freshMinimum);
    Console.WriteLine(policy.ToString());
    return policy;
}

注釈

cacheAgeControl値は、freshOrStale パラメーター値の意味を解釈し、関連付けられたプロパティを設定するために使用されます。 たとえば、 MaxStaleを指定すると、 MaxStale プロパティは freshOrStale パラメーターの値に設定されます。 MaxAgeAndMaxStaleを指定すると、MaxAge プロパティは maxAge パラメーターの値を使用して設定され、MaxStale プロパティは freshOrStale パラメーターの値を使用して設定されます。

MaxAgeAndMaxStaleまたはMaxAgeAndMinFreshを指定しない限り、MaxAge プロパティは設定されないことに注意してください。

このコンストラクターは、 Level プロパティを初期化して Defaultします。

適用対象

HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime)

ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs
ソース:
HttpRequestCachePolicy.cs

指定した最大有効期間、年齢制御値、時刻値、キャッシュ同期日付を使用して、 HttpRequestCachePolicy クラスの新しいインスタンスを初期化します。

public:
 HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan * TimeSpan * DateTime -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, maxAge As TimeSpan, freshOrStale As TimeSpan, cacheSyncDate As DateTime)

パラメーター

cacheAgeControl
HttpCacheAgeControl

HttpCacheAgeControl価値。

maxAge
TimeSpan

リソースの最大有効期間を指定する TimeSpan 値。

freshOrStale
TimeSpan

時間を指定する TimeSpan 値。

cacheSyncDate
DateTime

キャッシュに格納されているリソースを再検証する必要がある時刻を指定する DateTime オブジェクト。

次のコード例では、最小鮮度、最大有効期間、キャッシュ同期日付に基づいてキャッシュ ポリシーを作成する方法を示します。

public static HttpRequestCachePolicy CreateFreshAndAgePolicy2(TimeSpan freshMinimum, TimeSpan ageMaximum, DateTime when)
{
    HttpRequestCachePolicy policy =
        new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, ageMaximum, freshMinimum, when);
    Console.WriteLine(policy.ToString());
    return policy;
    // For the following invocation:
    // CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0),);
    // the output is:
    // Level:Automatic
    // AgeControl:MinFreshAndMaxAge
    // MinFresh:18000
    // MaxAge:36000
}

注釈

cacheAgeControl値は、freshOrStale パラメーター値の意味を解釈し、関連付けられたプロパティを設定するために使用されます。 たとえば、 MaxStaleを指定すると、 MaxStale プロパティは freshOrStale パラメーターの値に設定されます。 MaxAgeAndMaxStaleを指定すると、MaxAge プロパティは maxAge パラメーターの値を使用して設定され、MaxStale プロパティは freshOrStale パラメーターの値を使用して設定されます。

MaxAgeAndMaxStaleまたはMaxAgeAndMinFreshを指定しない限り、MaxAge プロパティは設定されないことに注意してください。

このコンストラクターは、 CacheSyncDate プロパティを初期化して cacheSyncDateし、 Level プロパティを初期化して Defaultします。

適用対象