公開 HTTP 用戶端的快取組態。
Syntax
class HttpClientCache : EmbeddedObject
方法
這個類別不包含方法。
屬性
下表列出 類別所 HttpClientCache 公開的屬性。
| 名稱 | 描述 |
|---|---|
CacheControlCustom |
讀取/寫入 string 值,指定要新增至回應的 HTTP 1.1 Cache-Control 標頭。 |
CacheControlMaxAge |
讀取/寫入 datetime 值,指定 HTTP 1.1 快取控制項的最大存留期。 預設為 1 天。 |
CacheControlMode |
讀取/寫入 sint32 列舉,指定要用於用戶端快取的模式。 可能的值稍後會列在一節中。 |
HttpExpires |
讀取/寫入 string 值,指定在要求批註 (RFC) 1123 格式中,快取回應視為過時的日期和時間。 |
子類別
這個類別不包含子類別。
備註
這個類別的實例包含在StaticContentSection類別的陣列屬性中 ClientCache 。
下表包含 屬性的可能值 CacheControlMode 。 預設值為 0 (NoControl) 。
| 值 | 關鍵字 | 描述 |
|---|---|---|
| 0 | NoControl |
不會將 或 Expires 標頭新增 Cache-Control 至回應。 |
| 1 | DisableCache |
將 Cache-Control: no-cache 標頭加到回應中。 |
| 2 | UseMaxAge |
Cache-Control: max-age=<nnn>根據 屬性中指定的 CacheControlMaxAge 值,將標頭加入回應中。 |
| 3 | UseExpires |
Expires: <date>根據 屬性中指定的 HttpExpires 日期,將標頭加入回應中。 |
如需標頭欄位的詳細資訊,請參閱要求批註 (RFC) 2616「超文字傳輸通訊協定 -- HTTP/1.1」。
如需日期和時間格式的詳細資訊,請參閱 RFC 1123:「網際網路主機的需求 -- 應用程式和支援」。
範例
下列範例會顯示 類別的屬性 HttpClientCache 。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Retrieve the static content section.
Set oSection = oWebAdmin.Get("StaticContentSection.Path=" & _
"'MACHINE/WEBROOT/APPHOST',Location=''")
' Show the path and location.
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location
WScript.Echo
Display the embedded HttpClientCache properties.
Set ohttpClientCache = oSection.ClientCache
WScript.Echo "HttpClientCache properties"
WScript.Echo "--------------------------"
WScript.Echo "CacheControlCustom: " & ohttpClientCache.CacheControlCustom
WScript.Echo "CacheControlMaxAge: " & ohttpClientCache.CacheControlMaxAge
WScript.Echo "CacheControlMode: " & _
GetCacheControlModeText(ohttpClientCache.CacheControlMode)
WScript.Echo "HttpExpires: " & ohttpClientCache.HttpExpires
' Provide text for CacheControlMode enumeration values.
Function GetCacheControlModeText(uint32Mode)
Select Case uint32Mode
Case 0
GetCacheControlModeText="NoControl"
Case 1
GetCacheControlModeText="DisableCache"
Case 2
GetCacheControlModeText="UseMaxAge"
Case 3
GetCacheControlModeText="UseExpires"
Case Else
GetCacheControlModeText="Unknown Mode"
End Select
End Function
繼承階層架構
HttpClientCache
規格需求
| 類型 | 描述 |
|---|---|
| Client | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10上的 IIS 10.0 |
| 伺服器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016上的 IIS 10.0 |
| 產品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
| MOF 檔案 | WebAdministration.mof |
另請參閱
EmbeddedObject 類別
StaticContentSection 類別
CIM_DATETIME
Datetime.Parse 方法