FtpWebRequest.DefaultCachePolicy 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義所有 FTP 請求的預設快取政策。
public:
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; }
public static System.Net.Cache.RequestCachePolicy DefaultCachePolicy { get; set; }
static member DefaultCachePolicy : System.Net.Cache.RequestCachePolicy with get, set
Public Shared Property DefaultCachePolicy As RequestCachePolicy
屬性值
一個 RequestCachePolicy 定義 FTP 請求快取政策的方案。
例外狀況
呼叫者嘗試將此屬性設定為 null。
備註
只有使用該 DownloadFile 指令接收的內容才會被快取。
下表描述了 FTP 快取政策對 FtpWebRequest的影響。
| 原則 | 影響 |
|---|---|
| Default | 若資源是新鮮的、內容長度準確,且有到期、修改及內容長度屬性,則回傳快取資源。 |
| BypassCache | 從伺服器回傳資源。 |
| CacheOnly | 若內容長度存在且條目大小相符,則回傳快取資源;否則,會拋出 WebException。 |
| CacheIfAvailable | 若提供內容長度且與條目大小相符,則回傳快取資源;否則,資源會從伺服器下載並返回呼叫者。 |
| Revalidate | 若快取資源的時間戳記與伺服器資源的時間戳相同,則回傳快取資源;否則,資源會從伺服器下載,儲存在快取中,然後返回給呼叫者。 |
| Reload | 從伺服器下載資源,儲存在快取中,然後將資源回傳給呼叫者。 |
| NoCacheNoStore | 如果存在快取資源,該資源會被刪除。 資源會從伺服器下載並返回給呼叫者。 |
Note
設定 DefaultCachePolicy 會覆蓋任何設定設定。