| title | IHttpCachePolicy::IsUserCacheEnabled Method |
|---|---|
| ms.date | 10/07/2016 |
| description | Learn how to return a value that indicates whether user caching is enabled for the cache policy. |
| ms.assetid | ff83d13d-ba1d-2075-8231-df9d7877e96a |
Returns a value that indicates whether user caching is enabled for the cache policy.
virtual BOOL IsUserCacheEnabled(
VOID
) const = 0; This method takes no parameters.
true if user caching is enabled for the cache policy; otherwise, false.
CHttpModule derived classes that register for request or response events receive an IHttpContext pointer as a parameter on the corresponding virtual method. Call the IHttpContext::GetResponse method, then the IHttpResponse::GetCachePolicy method, and finally the IsUserCacheEnabled method to determine if user caching is enabled for the cache policy.
IsUserCacheEnabled behavior depends on implementation. You should use the following information as a guideline, but it may not be correct in all scenarios:
-
The current default implementer of the IHttpCachePolicy interface declares a
privateBoolean that determines whether caching is enabled for a user. During the construction of an implementer, this Boolean is initialized totrue. When the DisableUserCache method is called, this Boolean is set tofalse. Once caching is disabled for a user, there is no method to reset this Boolean totrue. -
IsUserCacheEnabledreturns the value of this Boolean.
The following code example demonstrates how to create a global module that listens for RQ_BEGIN_REQUEST and RQ_SEND_RESPONSE events. The module then retrieves an IHttpCachePolicy pointer and writes user cache information to the response stream.
[!code-cppIHttpCachePolicy#11]
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 data that is similar to the following to the response stream:
User Cache Enabled: true
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 |