HTTP Response Cache

by Walter Oliver

The IIS output cache is a feature that makes it possible to cache entire responses in memory, even from dynamic content. Unlike the caches in IIS 6.0, IIS 7.0 and above have a "smart" cache, which lets site owners and developers configure the output cache to cache separate copies of responses based on query string value. The output cache is also integrated with the HTTP.sys kernel cache that helps with fast performance. Kernel caching is unlocked by default. Developers can take advantage of this feature by configuring caching profiles within their application. You can run a command line tool that shows what content is in the HTTP.sys cache.

To view the HTTP response cache using netsh

  • Open a command prompt and run the following:

netsh http show cache

To Enable Caching using the IIS PowerShell Provider

  • Open the PowerShell prompt and type:
set-webconfigurationproperty /system.webServer/caching iis:\sites\mysite -name enabled -value true

To add a new entry using the IIS PowerShell Provider

  • Add extra properties the hash -value @{...}
add-webconfigurationproperty /system.webServer/caching iis:\sites\mysite `-name profiles `-value @{extension='.tif'; policy='CacheForTimePeriod';duration='00:00:10'}

To change setting for caching entry

  • get specific entry:
$cacheEntry = get-webconfigurationproperty /system.webServer/caching iis:\sites\mysite -atElement @{extension='.tif'}
  • change attribute
$cacheEntry.Duration = [TimeSpan]::FromSeconds(10)
$cacheEntry.kernelCachePolicy = 'CacheForTimePeriod'
set-webconfigurationproperty /system.webServer/caching iis:\sites\mysite `
    -name profiles `
    -atElement @{extension='.tif'} `
    -value $cacheEntry