HttpWebRequest.DefaultCachePolicy 屬性


取得或設定這個要求的預設快取原則。Gets or sets the default cache policy for this request.

 static property System::Net::Cache::RequestCachePolicy ^ DefaultCachePolicy { System::Net::Cache::RequestCachePolicy ^ get(); void set(System::Net::Cache::RequestCachePolicy ^ value); };
public static System.Net.Cache.RequestCachePolicy DefaultCachePolicy { get; set; }
member this.DefaultCachePolicy : System.Net.Cache.RequestCachePolicy with get, set
Public Shared Property DefaultCachePolicy As RequestCachePolicy



HttpRequestCachePolicy,在沒有其他適用的原則時,為這個要求指定作用中的快取原則。A HttpRequestCachePolicy that specifies the cache policy in effect for this request when no other policy is applicable.


設定此屬性會為 HTTP 和 HTTPS 配置註冊指定的原則。Setting this property registers the specified policy for the HTTP and HTTPS schemes. 此原則用於此要求,如果:This policy is used for this request if:

WebRequest.CachePolicy 指定此要求的屬性。There is no WebRequest.CachePolicy property specified for this request.


電腦和應用程式佈建檔案並未指定適用于統一資源識別元的快取原則, (URI) 用來建立此要求。The machine and application configuration files do not specify a cache policy that is applicable to the Uniform Resource Identifier (URI) used to create this request.

快取原則會決定是否可以從快取中取得所要求的資源,而不是將要求傳送至資源主機電腦。The cache policy determines whether the requested resource can be taken from a cache instead of sending the request to the resource host computer.

只有在抓取資源的回應資料流程並讀取至資料流程結尾時,才會將資源複本新增至快取。A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. 因此,相同資源的另一個要求可以使用快取的複本,視此要求的快取原則層級而定。So another request for the same resource could use a cached copy, depending on the cache policy level for this request.