Configure an Output Caching Rule Using Headers (IIS 7)

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

You can configure a rule based on response headers that will cache different versions of content in your site or application.

Important

Make sure that you put limits on the cache size when you configure an output cache rule to use response headers. This will help prevent the cache from growing too quickly.

For example, you might have different versions of content in your site or application to suit different Web browsers. You can configure an output cache rule to cache different versions of the page based on the browser type that is returned in the HTTP User-Agent header. Then when a client requests a page in your site or application, they will get a cached version of the page specific to their browser type if one is available in the cache.

Prerequisites

For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Output Caching Feature Requirements (IIS 7).

Exceptions to feature requirements

  • None

To configure an Output Cache Rule Using Headers

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

User Interface

To use the UI

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).

  2. In Features View, double-click Output Caching.

  3. Click Add in the Actions pane.

  4. In the Add Cache Rule dialog box, in the File Name Extension box, enter the file name extension, such as .aspx, for which you want to create a cache rule.

  5. Select the User-mode caching check box to enable output caching, and select one of the following options:

    • Using file change notification: if you want an item to be removed from the cache when it is updated.

    • At time intervals (hh:mm:ss): if you want an item to be removed from the cache after a certain time elapses.

    • Prevent all caching: to prevent all caching of the designated file type.

  6. Click Advanced.

  7. In the Advanced Output Cache Rule Settings dialog box, click to select Headers under Cache different versions of a file based on.

  8. Type a response header, such as Accept-Language or Accept-Charset, in the Headers box and then click OK.

Command Line

To <do_something>, use the following syntax:

appcmd command object parameter:value | parameter:variable | parameter:option1 | option2

The variable <variable_name> is <description_of_variable>. For example, to <do_something_specific>, type the following at the command prompt, and then press ENTER:

appcmd <exact_command_to_accomplish_the_procedure>

Note

When you use Appcmd.exe to configure the <element_name> element at the global level in IIS 7, you must specify /commit:WEBROOT in the command so that configuration changes are made to the root Web.config file instead of ApplicationHost.config.

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

Configuration

The procedure in this topic affects the following configuration elements:

<profiles>

For more information about IISĀ 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.

See Also

Concepts

View a List of Output Caching Rules (IIS 7)
Add an Output Caching Rule (IIS 7)
Configure an Output Caching Rule Using Query Strings (IIS 7)