แก้ไข

แชร์ผ่าน


HttpRequestCachePolicy.MaxAge Property

Definition

Gets the maximum age permitted for a resource returned from the cache.

public:
 property TimeSpan MaxAge { TimeSpan get(); };
public TimeSpan MaxAge { get; }
member this.MaxAge : TimeSpan
Public ReadOnly Property MaxAge As TimeSpan

Property Value

A TimeSpan value that is set to the maximum age value specified when this instance was created. If no date was specified, this property's value is DateTime.MinValue.

Examples

The following code example demonstrates displaying the value of this property.

static HttpRequestCachePolicy^ CreateMaxAgePolicy( TimeSpan span )
{
   HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAge,span );
   Console::WriteLine( L"Max age is {0}", policy->MaxAge );
   return policy;
}
public static HttpRequestCachePolicy CreateMaxAgePolicy(TimeSpan span)
{
    HttpRequestCachePolicy policy =
        new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAge, span);
    Console.WriteLine("Max age is {0}", policy.MaxAge);
    return policy;
}

Remarks

If the cached copy of the resource is older than the specified time value, the resource must be revalidated. The value for this property is specified when the instance is constructed.

Applies to