HttpRequestCachePolicy Constructor (HttpCacheAgeControl, TimeSpan, TimeSpan)
Initializes a new instance of the HttpRequestCachePolicy class using the specified maximum age, age control value, and time value.
Assembly: System (in System.dll)
public:
HttpRequestCachePolicy(
HttpCacheAgeControl cacheAgeControl,
TimeSpan maxAge,
TimeSpan freshOrStale
)
Parameters
- cacheAgeControl
-
Type:
System.Net.Cache::HttpCacheAgeControl
An HttpCacheAgeControl value.
- maxAge
-
Type:
System::TimeSpan
A TimeSpan value that specifies the maximum age for resources.
- freshOrStale
-
Type:
System::TimeSpan
A TimeSpan value that specifies an amount of time. See the Remarks section for more information.
| Exception | Condition |
|---|---|
| ArgumentException | The value specified for the cacheAgeControl parameter is not valid. |
The cacheAgeControl value is used to interpret the meaning of the freshOrStale parameter value and set the associated property. For example, when you specify MaxStale, the MaxStale property is set to the value of the freshOrStale parameter. When you specify MaxAgeAndMaxStale, the MaxAge property is set using the value of the maxAge parameter and the MaxStale property is set using the value of the freshOrStale parameter.
Note that unless you specify MaxAgeAndMaxStale or MaxAgeAndMinFresh, the MaxAge property is not set.
The following code example demonstrates creating a cache policy based on minimum freshness and maximum age.
Available since 2.0