Windows 7 / Getting Started

Handling HTTP Responses

The HTTP response headers you send with a response to a request help determine how the client reacts to the information. In some cases, the response header can request additional information or tell the client which forms of input the server supports. You can use custom responses to provide the client with special information about your Web site.

Note:
The important thing to remember about response headers is that they don't appear in the browser. The user won't see anything special by simply looking at the Web page with a browser. If the user views the source for your Web page, they see the special headers, but most users won't perform this task. In general, the browser must know how to work with the response header, or you must use a special application designed to react to your custom headers to make the response headers useful.

IIS 7 supports both standard and custom response headers. You can see the standard response headers at http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html. The information at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html tells you about formatting these response headers. (IIS 7 usually does a good job of performing this task for you as long as you provide the right information.) It's also important to view the list of response headers that Microsoft supports at http:// msdn2.microsoft.com/en-us/library/ms537417.aspx. The following sections tell you how to configure standard and custom response headers.

Configuring a standard response header

IIS 7 supports only two of the many standard response headers directly: HTTP Keep Alive and Expire Web Content. If you want to set any other standard header, you must do it as a custom response header, as shown in the "Configuring a custom response header" section of this tutorial. The following steps describe how to set a standard response header:

  1. Double-click the HTTP Response Headers icon.
    You see the HTTP Response Headers window.
  2. Click Set Common Headers in the Actions pane.
    You see the Set Common HTTP Response Headers dialog box.
  3. (Optional) Check Enable HTTP Keep Alive.
    IIS enables this option by default. Using this option improves server performance significantly and there isn't a good reason to disable it. An HTTP keep-alive ensures that the connection between the client and server remains open when the server must send multiple elements to the client. Most modern Web pages include multiple elements. The Web page itself is an element, as is every graphic and any other content contained within the Web page. Opening a new connection every time the server has to send one of these elements can consume considerable time and doesn't serve any useful purpose.
  4. (Optional) Check Expire Web Content.
    Use this option to force the browser to update information from the Web server rather than use cached data on the server. This feature is important when the content on your Web site changes frequently, even though the URL doesn't. If the content is completely static (doesn't change), clearing this option can save considerable server resources and improve performance. If you check this option, you also need to choose one of the following update intervals:
    • Immediately: Use this option if you want the client to refresh its data from the server with every request.
    • After: Use this option when the content changes regularly but not constantly. For example, if the information on your Web site changes once a day, the client needs to update its local cache only once a day. Setting the interval correctly can save server resources and improve performance.
    • On: Use this option when you know that the content on your Web site will change at a specific date and time. For example, you can use this setting to ensure that the client sees an announcement of a new product on a Web page that normally contains only static data.
  5. Click OK.
    IIS 7 closes the Set Common HTTP Response Headers dialog box. You don't see any changes in the HTTP Response Headers window.
  6. Click Apply to make the settings active.

Configuring a custom response header

A custom response header can contain any information. The client must know how to handle the information, but otherwise there are no limits on what you can include. The following steps tell how to create a custom response header:

  1. Double-click the HTTP Response Headers icon.
    You see the HTTP Response Headers window.
  2. Click Add.
    You see the Add Custom HTTP Response Header dialog box.
  3. Type the name of the custom response header in the Name field.
    When working with a standard header that IIS 7 doesn't support directly, make sure to type the response header name precisely to ensure that the client responds to it.
  4. Type the value of the custom response header in the Value field.
    When working with a standard header, make absolutely certain that you type the value correctly. The common practice is to separate multiple values with a semicolon (;). Don't type quotes around the value - IIS 7 adds them for you.
  5. Click OK.
    You see the custom response header added to the list of headers in the HTTP Response Headers window.
  6. Click Apply to make the settings active.
    You may eventually need to edit or remove custom response headers. To edit a response header, highlight its entry in the list and click Edit in the Actions pane. To remove a response header, highlight its entry in the list and click Remove in the Actions pane. Any changes you make to the response headers list appear the moment you click Apply in the Actions pane.
[Previous] [Contents] [Next]