| title | IHttpFileInfo::GetHttpCacheAllowed Method |
|---|---|
| description | Describes the IHttpFileInfo::GetHttpCacheAllowed method and details its syntax, parameters, return value, remarks, code example, and requirements. |
| ms.date | 10/07/2016 |
| ms.assetid | a46e00e7-47ae-2359-120d-0883ee73f8a9 |
Returns a value that indicates whether the corresponding file can be cached.
virtual BOOL GetHttpCacheAllowed(
OUT DWORD* pSecondsToLive
) const = 0; pSecondsToLive
[OUT] A pointer to a DWORD that contains the number of seconds that the cached file will be held.
true if the corresponding file may be cached; otherwise, false.
While the pSecondsToLive parameter must not be NULL, inspect this parameter only if the GetHttpCacheAllowed method returns true. If that is the case, IHttpFileInfo implementers are not required to set this output parameter before return.
The behavior of the GetHttpCacheAllowed method is implementation specific. You should use the following information as a guideline, but it may not be correct in all scenarios:
-
Implementers that reference an Internet file return
false. -
Implementers that reference a non-Internet file return
trueif caching is enabled for the file type.
The following code example demonstrates how to use the IHttpContext::GetFileInfo method to create an HTTP module that retrieves a pointer to an IHttpFileInfo interface for the current request. The example then calls the GetHttpCacheAllowed method to retrieve cache information for the requested file and displays this information to a Web client.
[!code-cppIHttpFileInfo#9]
The following text is a sample of the data output from the preceding code example.
HTTP/1.1 200 OK
content-Type:text/plain
Server: Microsoft-IIS/7.0
Date: Thu, 15 Dec 2005 22:22:09 GMT
Content-Length: 348
Cache Allowed: true
Time-to-Live: -1
Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
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 |