| title | IHttpCachePolicy Interface |
|---|---|
| description | Learn how the IHttpCachePolicy interface provides CHttpModule derived classes access to the setting and getting policy for request caching. |
| ms.date | 10/07/2016 |
| ms.assetid | 25090637-88d3-52df-17bc-9560fa3d92dc |
Provides CHttpModule derived classes access to the setting and getting policy for request caching.
class IHttpCachePolicy The following table lists the methods exposed by the IHttpCachePolicy class.
| Name | Description |
|---|---|
| AppendVaryByHeader | Appends the header value to the cache policy. |
| AppendVaryByQueryString | Appends the query value to the cache policy. |
| DisableUserCache | Disables user caching for the cache policy. |
| GetKernelCacheInvalidatorSet | Gets a value that indicates whether the kernel cache is invalidated. |
| GetKernelCachePolicy | Returns the cache policy for the kernel. |
| GetUserCachePolicy | Returns the cache policy for the user. |
| GetVaryByHeaders | Returns the custom header values for the cache policy. |
| GetVaryByQueryStrings | Returns the custom query values for the cache policy. |
| GetVaryByValue | Returns the variable value for the cache policy. |
| IsCached | Returns a value that indicates whether the cache policy is enabled. |
| IsUserCacheEnabled | Returns a value that indicates whether user caching is enabled for the cache policy. |
| SetIsCached | Sets a value that indicates that the data is cached. |
| SetKernelCacheInvalidatorSet | Sets a value that indicates that the kernel cache is invalidated. |
| SetVaryByValue | Sets the variable value for the cache policy. |
This class contains no properties.
| Name | Description |
|---|---|
| IHttpCachePolicy2 | Provides CHttpModule derived classes access to the setting and getting policy for request caching. |
CHttpModule derived classes that register for request or response events receive an IHttpContext pointer as a parameter on the corresponding virtual method.
The following code example demonstrates how to create a global module that listens for RQ_BEGIN_REQUEST and RQ_SEND_RESPONSE events, and then sets IHttpCachePolicy data and returns that data to the browser as an XML document.
[!code-cppIHttpCachePolicy#1]
For more information on how to create and deploy a native DLL module, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
The above code writes an XML document that is similar to the following to the response stream:
<?xml version="1.0"?>
<response>
<httpCachePolicy
varyByHeaders="header1,header2"
varyByQuery="query1,query2"
varyByValue="vary"
isCached="true"
isUserCacheEnabled="false">
<cachePolicy
kernelPolicy="HttpCachePolicyUserInvalidates"
secondsToLive="2"/>
<cachePolicy
userPolicy="HttpCachePolicyMaximum"
secondsToLive="5"/>
</httpCachePolicy>
</response>
You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.
| Type | Description |
|---|---|
| Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
| Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
| Header | Httpserv.h |