HttpRequestCachePolicy.MaxAge Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Net.Cache
Assembly:  System (in System.dll)

public TimeSpan MaxAge { get; }

Property Value

Type: System.TimeSpan

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 MinValue.

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.

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

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

.NET Framework
Available since 2.0
Return to top
Show: