Condividi tramite


<requestCaching> Element (Network Settings) 

Controls the caching mechanism for network requests.

<requestCaching
  isPrivateCache ="true|false"
  disableAllCaching="true|false"
  defaultPolicyLevel="BypassCache|Default|CacheOnly|CacheIfAvailable|Revalidate|Reload|NoCacheNoStore|Revalidate"
  unspecifiedMaximumAge= "d.hh.mm.ss""
  <defaultHttpCachePolicy> … </defaultHttpCachePolicy>
  <defaultFtpCachePolicy> … </defaultFtpCachePolicy>
/>

Attributes and Elements

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

Attributes

Attribute Description

isPrivateCache

Specifies whether the cache provides isolation between the information of different users. The default value is true. This value should be false for middle tier applications.

disableAllCaching

Specifies that caching is disabled for all Web responses, and cannot be overridden programmatically.

defaultPolicyLevel

One of the values in the RequestCacheLevel enumeration. The default value is BypassCache.

unspecifiedMaximumAge

Specifies the default time after which content is marked as expired.

policyLevel Attribute

Value Description

Default

Returns the cached resource if the resource is fresh, the content length is accurate, and the expiration, modification, and content length attributes are present.

BypassCache

Returns the resource from the server.

CacheOnly

Returns the cached resource if the content length is present and matches the entry size.

CacheIfAvailable

Returns the cached resource if the content length is provided and matches the entry size; otherwise, the resource is downloaded from the server and is returned to the caller.

Revalidate

Returns the cached resource if the timestamp of the cached resource is the same as the timestamp of the resource on the server; otherwise, the resource is downloaded from the server, stored in the cache, and is returned to the caller.

Reload

Downloads the resource from the server, stores it in the cache, and returns the resource to the caller.

NoCacheNoStore

If a cached resource exists, it is deleted. The resource is downloaded from the server and is returned to the caller.

Revalidate

Satisfies a request by using the cached copy of the resource if the timestamp is the same as the timestamp of the resource on the server; otherwise, the resource is downloaded from the server, presented to the caller, and is stored in the cache,

Child Elements

Element Description

defaultHttpCachePolicy

Optional element.

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

<defaultFtpCachePolicy> Element (Network Settings)

Optional element.

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

Parent Elements

Element Description

system.net

Contains settings that specify how the .NET Framework connects to the network.

Example

The following code example shows how to disable all caching.

<configuration>
  <system.net>
    <requestCaching
      disableAllCaching="true"
    />
  </system.net>
</configuration>

See Also

Reference

Network Settings Schema
Cache