IHttpCachePolicy Interface

IIS 7.0
 

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.

Example

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.

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.

Requirements

Type

Description

Client

  • IIS 7.0 on Windows Vista

  • IIS 7.5 on Windows 7

  • IIS 8.0 on Windows 8

  • IIS 10.0 on Windows 10

Server

  • IIS 7.0 on Windows Server 2008

  • 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 Technical Preview

Product

  • IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0

  • IIS Express 7.5, IIS Express 8.0, IIS Express 10.0

Header

Httpserv.h

Show: