Condividi tramite


Classe HttpClientCache

Espone la configurazione della memorizzazione nella cache per un client HTTP.

Sintassi

class HttpClientCache : EmbeddedObject  

Metodi

Questa classe non contiene metodi.

Proprietà

Nella tabella seguente sono elencate le proprietà esposte dalla HttpClientCache classe .

Nome Descrizione
CacheControlCustom Valore di lettura/scrittura string che specifica un'intestazione HTTP 1.1 Cache-Control da aggiungere alla risposta.
CacheControlMaxAge Valore di lettura/scrittura datetime che specifica l'età massima per il controllo cache HTTP 1.1. Il valore predefinito è 1 giorno.
CacheControlMode Enumerazione di lettura/scrittura sint32 che specifica la modalità da usare per la memorizzazione nella cache client. I valori possibili sono elencati più avanti nella sezione Osservazioni.
HttpExpires Valore di lettura/scrittura string che specifica, nel formato Request for Comments (RFC) 1123, la data e l'ora dopo la quale viene considerata non aggiornata una risposta memorizzata nella cache.

Sottoclassi

Questa classe non contiene sottoclassi.

Commenti

Le istanze di questa classe sono contenute nella ClientCache proprietà array della classe StaticContentSection .

La tabella seguente contiene i valori possibili per la CacheControlMode proprietà. Il valore predefinito è 0 (NoControl).

Valore Parola chiave Descrizione
0 NoControl Non aggiunge un'intestazione Cache-Control o Expires alla risposta.
1 DisableCache Aggiunge un'intestazione Cache-Control: no-cache alla risposta.
2 UseMaxAge Aggiunge un'intestazione Cache-Control: max-age=<nnn> alla risposta in base al valore specificato nella CacheControlMaxAge proprietà.
3 UseExpires Aggiunge un'intestazione Expires: <date> alla risposta in base alla data specificata nella HttpExpires proprietà.

Per altre informazioni sui campi di intestazione, vedere Request for Comments (RFC) 2616, "Hypertext Transfer Protocol -- HTTP/1.1".

Per altre informazioni sui formati di data e ora, vedere RFC 1123, "Requisiti per gli host Internet - Applicazione e supporto".

Esempio

Nell'esempio seguente vengono visualizzate le proprietà per la HttpClientCache classe.

' 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  

Gerarchia di ereditarietà

EmbeddedObject

HttpClientCache

Requisiti

Tipo Descrizione
Client - IIS 7.0 in Windows Vista
- IIS 7.5 in Windows 7
- IIS 8.0 in Windows 8
- IIS 10.0 in Windows 10
Server - IIS 7.0 in Windows Server 2008
- IIS 7.5 in Windows Server 2008 R2
- IIS 8.0 in Windows Server 2012
- IIS 8.5 in Windows Server 2012 R2
- IIS 10.0 in Windows Server 2016
Prodotto - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
File MOF WebAdministration.mof

Vedere anche

Classe EmbeddedObject
Classe StaticContentSection
CIM_DATETIME
Metodo Datetime.Parse