HttpCacheAgeControl 枚举


指定时间值的含义,这些时间值控制使用 HttpWebRequest 对象获取的资源的缓存行为。Specifies the meaning of time values that control caching behavior for resources obtained using HttpWebRequest objects.

public enum class HttpCacheAgeControl
public enum HttpCacheAgeControl
type HttpCacheAgeControl = 
Public Enum HttpCacheAgeControl


MaxAge 2

在内容超出用该值指定的生存期之前,可以从缓存中取出内容。Content can be taken from the cache until it is older than the age specified with this value.

MaxAgeAndMaxStale 6

MaxAgeMaxStaleMaxAge and MaxStale.

MaxAgeAndMinFresh 3

MaxAgeMinFreshMaxAge and MinFresh.

MaxStale 4

在内容过期后到用该值指定的时间结束之前,可以将内容从缓存中取出。Content can be taken from the cache after it has expired, until the time specified with this value elapses.

MinFresh 1

如果在过期前剩余的时间大于或等于用该值指定的时间,则可以将内容从缓存中取出。Content can be taken from the cache if the time remaining before expiration is greater than or equal to the time specified with this value.

None 0

仅限内部使用。For internal use only. 如果您尝试使用此成员,则 Framework 将引发 ArgumentExceptionThe Framework will throw an ArgumentException if you try to use this member.


下面的代码示例基于 MaxAgeAndMinFresh 创建一个策略。The following code example creates a policy based on MaxAgeAndMinFresh.

static HttpRequestCachePolicy^ CreateFreshAndAgePolicy( TimeSpan freshMinimum, TimeSpan ageMaximum )
   HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAgeAndMinFresh,
       ageMaximum, freshMinimum );
   Console::WriteLine( policy );
   return policy;
public static HttpRequestCachePolicy CreateFreshAndAgePolicy(TimeSpan freshMinimum, TimeSpan ageMaximum)
    HttpRequestCachePolicy policy = 
        new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, ageMaximum, freshMinimum); 
    return policy; 


此枚举由HttpRequestCachePolicy类的成员用于配置缓存策略的时间值。This enumeration is used by members of the HttpRequestCachePolicy class to configure the time values for cache policies.