Export (0) Print
Expand All

HttpRequestCachePolicy Constructor (HttpCacheAgeControl, TimeSpan)

Initializes a new instance of the HttpRequestCachePolicy class using the specified age control and time values.

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

public HttpRequestCachePolicy(
	HttpCacheAgeControl cacheAgeControl,
	TimeSpan ageOrFreshOrStale
)

Parameters

cacheAgeControl
Type: System.Net.Cache.HttpCacheAgeControl

One of the following HttpCacheAgeControl enumeration values: MaxAge, MaxStale, or MinFresh.

ageOrFreshOrStale
Type: System.TimeSpan

A TimeSpan value that specifies an amount of time. See the Remarks section for more information.

ExceptionCondition
ArgumentException

The value specified for the cacheAgeControl parameter cannot be used with this constructor.

The cacheAgeControl value defines the meaning of the ageOrFreshOrStale parameter value and is used to set the associated property. For example, when you specify MaxStale, the MaxStale property is set to the value of the ageOrFreshOrStale parameter.

This constructor initializes the Level property to Default.

The following code example demonstrates creating a cache policy based on minimum freshness.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft