Configure the HTTP Expires Response Header (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Configure the HTTP expires response header when you want to specify the expiration of Web content. The server returns the header value to the client browser in an HTML file header. The browser compares that value with the current date to determine whether to display a page that is cached on the client computer or to request an updated page from the server.
Consider the following information when you configure the expires response header:
Content that is updated regularly, such as on a daily or weekly basis, should be configured to expire periodically.
Content that contains sensitive information that you do not want cached or that is updated very frequently should be configured to expire immediately.
Content that is not expected to change should be configured to expire in approximately one year.
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 HTTP Response Headers Feature Requirements (IIS 7).
Exceptions to feature requirements
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.
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).
In Features View, double-click HTTP Response Headers.
On the HTTP Response Headers page, in the Actions pane, click Set Common Headers.
In the Set Common HTTP Response Headers dialog box, select the Expire Web content check box and select one of the following options:
Select Immediately if you want content to expire immediately after it is sent in a response.
Select After if you want the content to expire periodically. Then, in the corresponding boxes, type an integer and select a time interval at which content expires. For example, type 1 and select Days if you want the content to expire daily.
Select On (in Coordinated Universal Time (UTC)) if you want the content to expire on a specific day and at a specific time. Then, in the corresponding boxes, select a date and time at which the content expires.
- Select Immediately if you want content to expire immediately after it is sent in a response.
To set the expires response header to expire content immediately, type the following command at the command prompt and then press ENTER:
appcmd set config /section:staticContent /clientCache.cacheControlMode:DisableCache
To set the expires response header to expire content periodically and to set the number of seconds, minutes, hours, or days at which to expire the content, use the following syntax:
appcmd set config /section:staticContent /clientCache.cacheControlMode:UseMaxAge /clientCache.cacheControlMaxAge: timeSpan
The variable timeSpan is the time at which to expire the content. The format for timeSpan is d.hh:mm:ss, where d is the optional number of days, hh is the number of hours, mm is the number of minutes, and ss is the number of seconds at which to expire the content. For example, to set the cache to expire every two days, type the following and then press ENTER:
appcmd set config /section:staticContent /clientCache.cacheControlMode:UseMaxAge /clientCache.cacheControlMaxAge:2.00:00:00
To set the expires response header to expire content on a specific date at a specific time, use the following syntax:
appcmd set config /section:staticContent /clientCache.cacheControlMode:UseExpires /clientCache.httpExpires:" string "
|The data type for the httpExpires attribute of the <clientCache> element is string. Therefore, make sure that you type the correct format as a three-character day followed by a comma, then the date, a three-character month, the year, and time in hh:mm:ss, plus UTC. The whole value must be enclosed in quotation marks. For example, /clientCache.httpExpires:"Fri, 28 Jul 2006 15:30:00 UTC". For more information about Appcmd.exe, see Configure the HTTP Expires Response Header (IIS 7).|
The procedure in this topic affects the following configuration elements:
<clientCache> element under <staticContent>
For more information about IIS 7 configuration, see IIS Settings Schema on MSDN.
Use the following WMI classes, methods, or properties to perform this procedure:
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.