<requestCaching> 項目 (網路設定)<requestCaching> Element (Network Settings)

控制網路要求的快取機制。Controls the caching mechanism for network requests.

<configuration> <configuration>
   <system.web >   <system.net>
     <requestcaching> >    <requestCaching>

語法Syntax

<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>  
</requestCaching>

屬性和元素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. 預設值是 trueThe default value is true. 中介層應用程式的這個值應該是 falseThis value should be false for middle tier applications.
disableAllCaching 指定停用所有 Web 回應的快取,而且無法以程式設計方式覆寫。Specifies that caching is disabled for all Web responses, and cannot be overridden programmatically.
defaultPolicyLevel RequestCacheLevel 列舉中的其中一個值。One of the values in the RequestCacheLevel enumeration. 預設值是 BypassCacheThe default value is BypassCache.
unspecifiedMaximumAge 指定將內容標示為過期的預設時間。Specifies the default time after which content is marked as expired.

policyLevel 屬性policyLevel Attribute

{2>值<2}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
defaultHttpCachePolicydefaultHttpCachePolicy 選擇性項目。Optional element.

描述 HTTP 快取是否作用中,並描述預設的快取原則。Describes whether HTTP caching is active and describes the default caching policy.
<defaultFtpCachePolicy > 元素(網路設定)<defaultFtpCachePolicy> Element (Network Settings) 選擇性項目。Optional element.

描述 FTP 快取是否作用中,並描述預設的快取原則。Describes whether FTP caching is active and describes the default caching policy.

父項目Parent Elements

項目Element 描述Description
system.netsystem.net 包含會指定 .NET Framework 如何連接至網路的設定。Contains settings that specify how the .NET Framework connects to the network.

範例Example

下列範例顯示如何停用所有快取。The following example shows how to disable all caching.

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

請參閱See also