Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 4.12 KB

File metadata and controls

58 lines (41 loc) · 4.12 KB
title IHttpCachePolicy::IsCached Method
description Describes the IHttpCachePolicy::IsCached method and details its syntax, parameters, return value, remarks, code example, and requirements.
ms.date 10/07/2016
ms.assetid c79e046a-5fd3-58d7-7962-1ff4120a06b3

IHttpCachePolicy::IsCached Method

Returns a value that indicates whether the cache policy is enabled.

Syntax

virtual BOOL IsCached(  
   VOID  
) const = 0;  

Parameters

This method takes no parameters.

Return Value

true if data is cached; otherwise, false.

Remarks

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 IsCached method to verify whether the data is cached.

IsCached 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 private Boolean that is initialized to false at construction. When the SetIsCached method is called, this Boolean is set to true. After SetIsCached is called, there is no method to reset this Boolean to false.

  • IsCached returns the value of this Boolean.

Example

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 cache information to the response stream.

[!code-cppIHttpCachePolicy#10]

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:

Is Cached: false  

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Requirements

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

See Also

IHttpCachePolicy Interface