<defaultHttpCachePolicy> Element (Network Settings)

Describes whether HTTP caching is active and describes the default caching policy.

<configuration>
  <system.net>
    <requestCaching>
      <defaultHttpCachePolicy>

Syntax

<defaultHttpCachePolicy  
  policyLevel="BypassCache|Default"  
  minimumFresh="d.hh:mm:ss|minValue|maxValue"  
  maximumAge="d.hh:mm:ss|minValue|maxValue"  
  maximumStale="d.hh:mm:ss|minValue|maxValue"  
/>  

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
maximumAge Specifies the maximum time interval before a cached object is marked as expired.
maximumStale Specifies the maximum time past the computed freshness time before a cached object is marked as expired.
minimumFresh Specifies the minimum time for a cached object to be considered fresh.
policyLevel Specifies whether the caching policy is automatic, or whether the cache is bypassed. The default value is BypassCache.

Child Elements

None

Parent Elements

Element Description
requestCaching Controls the caching mechanism for network requests.

Remarks

The value for the policyLevel attribute is either BypassCache or Default.

Values for the maximumAge, maximumStale, and minimumFresh elements are either an explicit time interval with a format of d.hh:mm:ss (days, hours, minutes, and seconds), or the constants minValue or maxValue, as appropriate.

Configuration Files

This element can be used in the application configuration file or the machine configuration file (Machine.config).

Example

The following example shows how to specify a minimum fresh time of six hours, a maximum age time of two days, and a maximum stale time of four hours.

<configuration>  
  <system.net>  
    <requestCaching>  
      <defaultHttpCachePolicy  
        minimumFresh="0.06:00:00"  
        maximumAge="2.00:00:00"  
        maximumStale="0.04:00:00"
      />  
    </requestCaching>  
  </system.net>  
</configuration>  

See also