HTTP プロトコル設定: <httpProtocol>

概要

<httpProtocol> 要素は、HTTP キープアライブ接続と、インターネット インフォメーション サービス (IIS) 7 が Web クライアントに送信するカスタムとリダイレクト両方の応答ヘッダーを構成します。

ブラウザーは、通常、Web ページ全体をダウンロードするために複数の要求を行います。 サーバーのパフォーマンスを向上させるため、ほとんどの Web ブラウザーは、これらの複数の要求を通してサーバーが接続を開いたままにすることを要求します。これは、HTTP キープアライブと呼ばれる機能です。 HTTP キープアライブを使わないと、グラフィックスなどの複数の要素を含むページに対して多数の要求を行うブラウザーでは、要素ごとに個別の接続が必要になる場合があります。 これらの追加の要求と接続には、余分なサーバー アクティビティとリソースが必要であり、サーバーの効率が低下します。 また、接続が増えると、ブラウザーの速度が大幅に低下し、特に低速の接続では応答性が低下します。

互換性

バージョン メモ
IIS 10.0 <httpProtocol> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <httpProtocol> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <httpProtocol> 要素は、IIS 8.0 では変更されませんでした。
IIS 7.5 <httpProtocol> 要素は、IIS 7.5 では変更されませんでした。
IIS 7.0 <httpProtocol> 要素は IIS 7.0 で導入されました。
IIS 6.0 <httpProtocol> 要素のallowKeepAlive 属性は、IIS 6.0 の AllowKeepAlive メタベース プロパティを置き換えるものです。

段取り

<httpProtocol> 要素は IIS 7 の既定のインストールに含まれています。

操作方法

Web サイトまたはアプリケーションで HTTP キープアライブを有効にする方法

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーの [スタート] をクリックし、[管理ツール] をポイントして、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウで、HTTP キープアライブを有効にするサイト、アプリケーション、またはディレクトリに移動します。

  3. [ホーム] ウィンドウで、[HTTP 応答ヘッダー] をダブルクリックします。
    Screenshot of the Default Web Site Home page. The H T T P Response Headers icon is highlighted.

  4. [HTTP 応答ヘッダー] ウィンドウで、[操作] ウィンドウの [共通ヘッダーの設定] をクリックします。
    Screenshot of the H T T P Response Headers page.

  5. [共通 HTTP 応答ヘッダーの設定] ダイアログ ボックスで、HTTP キープアライブを有効にするチェック ボックスをオンにして、[OK] をクリックします。
    Screenshot of the Set Common H T T P Response Headers dialog box.

構成

属性

属性 説明
allowKeepAlive 省略可能な Boolean 属性です。

キープアライブ処理を許可するか (true)、しないか (false) を指定します。

既定値は true です。

子要素

要素 説明
customHeaders Web サーバーからの応答で返されるカスタム応答ヘッダーを構成します。
redirectHeaders Web サーバーが要求をリダイレクトした場合にのみ応答で返される応答ヘッダーを構成します。

構成サンプル

次のコード サンプルでは、既定の Web サイトで HTTP キープアライブを有効にしています。

<configuration>
   <system.webServer>
      <httpProtocol allowKeepAlive="true" />
   </system.webServer>
</configuration>

Note

次の既定の <httpProtocol> 要素は、IIS 7 の ApplicationHost.config ファイルで構成されます。

<httpProtocol>
   <customHeaders>
      <clear />
      <add name="X-Powered-By" value="ASP.NET" />
   </customHeaders>
   <redirectHeaders>
      <clear />
   </redirectHeaders>
</httpProtocol>

サンプル コード

次のコード サンプルでは、既定の Web サイトで HTTP キープアライブを有効にしています。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/httpProtocol /allowKeepAlive:"True"

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetWebConfiguration("Default Web Site");

         ConfigurationSection httpProtocolSection = config.GetSection("system.webServer/httpProtocol");
         httpProtocolSection["allowKeepAlive"] = true;

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetWebConfiguration("Default Web Site")

      Dim httpProtocolSection As ConfigurationSection = config.GetSection("system.webServer/httpProtocol")
      httpProtocolSection("allowKeepAlive") = True

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site";

var httpProtocolSection = adminManager.GetAdminSection("system.webServer/httpProtocol", "MACHINE/WEBROOT/APPHOST/Default Web Site");
httpProtocolSection.Properties.Item("allowKeepAlive").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site"

Set httpProtocolSection = adminManager.GetAdminSection("system.webServer/httpProtocol", "MACHINE/WEBROOT/APPHOST/Default Web Site")
httpProtocolSection.Properties.Item("allowKeepAlive").Value = True

adminManager.CommitChanges()