HTTP 압축 <httpCompression>

개요

요소는 <httpCompression> IIS(인터넷 정보 서비스) 7에 대한 HTTP 압축 설정을 지정합니다. HTTP 압축은 압축된 파일을 수락할 수 있는 IIS와 클라이언트 브라우저 간에 더 빠른 전송 시간을 제공할 수 있습니다.

참고

HTTP 클라이언트는 적절한 HTTP 수락 인코딩 헤더를 전송하여 압축된 콘텐츠에 대한 통신을 시작해야 합니다. 클라이언트가 HTTP 압축을 수행할 수 없는 경우 해당 헤더를 전달하지 않으며 IIS 7은 항상 압축되지 않은 콘텐츠를 반환합니다.

IIS 7에서 사용하는 압축에는 두 가지 유형이 있습니다.

  • 정적 압축:

    IIS 7은 디렉터리 특성으로 지정된 경로에 압축된 정적 콘텐츠를 캐시하므로 이미 압축된 콘텐츠를 다시 압축할 필요가 없으므로 압축 성능이 향상됩니다. IIS 7에서 파일을 압축한 후 후속 요청에는 캐시 디렉터리에서 파일의 압축된 복사본이 제공됩니다.

    staticCompressionEnableCpuUsagestaticCompressionDisableCpuUsage 특성은 IIS 7이 CPU 사용량에 따라 정적 파일을 압축할 시기를 지정합니다.

    HTML 파일(*.html, *.htm), 텍스트 파일(*.txt), Microsoft Office 문서(*.doc, *.xls, *.ppt) 등 일반적으로 변경되지 않는 파일과 함께 정적 압축을 사용해야 합니다. 이러한 파일의 크기는 압축을 통해 줄일 수 있으므로 클라이언트 요청의 다운로드 시간을 줄이고 서버의 대역폭을 줄일 수 있습니다.

    참고

    *.jpg 및 *.png 파일과 같은 이미지 파일도 정적 파일이지만 일반적으로 이러한 이미지 파일이 이미 압축되어 있으므로 HTTP 압축의 이점을 누릴 수 없습니다.

  • 동적 압축:

    정적 압축과 달리 IIS 7은 클라이언트가 콘텐츠를 요청할 때마다 동적 압축을 수행하지만 압축된 버전은 디스크에 캐시되지 않습니다. 이 변경은 정적 콘텐츠와 동적 콘텐츠 간의 주요 차이로 인해 수행됩니다. 정적 콘텐츠는 변경되지 않습니다. 그러나 동적 콘텐츠는 일반적으로 애플리케이션에서 생성되는 콘텐츠이므로 ASP(Active Server Pages) 또는 ASP.NET 콘텐츠와 같이 자주 변경됩니다. 동적 콘텐츠는 자주 변경되어야 하므로 IIS 7은 이를 캐시하지 않습니다.

    dynamicCompressionEnableCpuUsagedynamicCompressionDisableCpuUsage 특성은 IIS 7이 CPU 사용량에 따라 동적 파일을 압축할 시기를 지정합니다.

IIS 7은 다음과 같은 두 가지 업계 표준 압축 체계를 지원합니다.

이러한 두 압축 구성표는 각각 요소의 <httpCompression> 요소를 사용하여 <schemes> 사용하도록 설정할 수 있습니다.

참고

<httpCompression> 요소는 IIS(인터넷 정보 서비스) 7에 대한 HTTP 압축 설정을 지정하지만 urlCompression<> 요소는 URL 네임스페이스에 대해 압축을 사용할 수 있는지 여부를 지정합니다.

호환성

버전 참고
IIS 10.0 <httpCompression> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 특성이 staticCompressionIgnoreHitFrequency IIS 8.5에 추가되었습니다.
IIS 8.0 <httpCompression> 요소가 IIS 8.0에서 수정되지 않았습니다.
IIS 7.5 IIS 7.5에서는 특성의 minFileSizeForComp 기본값이 변경되고 특성이 dynamicCompressionBufferLimit 추가되었습니다.
IIS 7.0 요소는 <httpCompression> IIS 7.0에서 도입되었습니다.
IIS 6.0 요소는 <httpCompression> 다음 IIS 6.0 메타베이스 속성을 대체합니다.
  • HcCacheControlHeader
  • HcCompressionDirectory
  • HcDoDiskSpaceLimiting
  • HcExpiresHeader
  • HcMaxDiskSpaceUsage
  • HcMinFileSizeForComp
  • HcNoCompressionForHttp10
  • HcNoCompressionForProxies
  • HcNoCompressionForRange
  • HcSendCacheHeaders

설치 프로그램

HTTP 압축은 일반적으로 IIS 7 이상의 기본 설치에서 사용할 수 있습니다. 그러나 정적 압축만 기본적으로 설치됩니다. 정적 또는 동적 압축을 설치하려면 다음 단계를 사용합니다.

Windows Server 2012 또는 Windows Server 2012 R2

  1. 작업 표시줄에서 서버 관리자를 클릭합니다.
  2. 서버 관리자관리 메뉴를 클릭한 다음 역할 및 기능 추가를 클릭합니다.
  3. 역할 및 기능 추가 마법사에서 다음을 클릭합니다. 설치 유형을 선택하고 다음을 클릭합니다. 대상 서버를 선택하고 다음을 클릭합니다.
  4. 서버 역할 페이지에서 웹 서버(IIS)를 확장하고 웹 서버를 확장하고 성능을 확장한 다음 정적 콘텐츠 압축 및/또는 동적 콘텐츠 압축을 선택합니다. 다음을 클릭합니다.
    정적 콘텐츠 압축이 선택되고 동적 콘텐츠 압축이 강조 표시된 웹 서버 및 성능 노드의 스크린샷 .
  5. 기능 선택 페이지에서 다음을 클릭합니다.
  6. 설치 선택 확인 페이지에서 설치를 클릭합니다.
  7. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows 8 또는 Windows 8.1

  1. 시작 화면에서 포인터를 왼쪽 아래 모서리로 이동하고 시작 단추를 마우스 오른쪽 단추로 클릭한 다음 제어판 클릭합니다.
  2. 제어판프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.
  3. 인터넷 정보 서비스를 확장하고, World Wide Web Services를 확장하고, 성능 기능을 확장한 다음, 동적 콘텐츠 압축 및/또는 정적 콘텐츠 압축을 선택합니다.
    동적 콘텐츠 압축 및 정적 콘텐츠 압축이 선택된 것을 보여 주는 확장된 World Wide Web 및 성능 기능 창의 스크린샷
  4. 확인을 클릭합니다.
  5. 닫기를 클릭합니다.

Windows Server 2008 또는 Windows Server 2008 R2

  1. 작업 표시줄에서 시작을 클릭하고 관리 도구를 가리킨 다음 서버 관리자 클릭합니다.
  2. 서버 관리자 계층 구조 창에서 역할을 확장한 다음 웹 서버(IIS)를 클릭합니다.
  3. 웹 서버(IIS) 창에서 Role Services 섹션으로 스크롤한 다음 역할 서비스 추가를 클릭합니다.
  4. 역할 서비스 추가 마법사역할 서비스 선택 페이지에서 동적 압축 및 정적 콘텐츠 압축을 설치하려면 동적콘텐츠 압축을 선택하고 정적 압축을 설치하려면 다음을 클릭합니다.
    동적 콘텐츠 압축이 강조 표시된 역할 서비스 추가 페이지에서 확장된 성능 노드의 스크린샷
  5. 설치 선택 확인 페이지에서 설치를 클릭합니다.
  6. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows Vista 또는 Windows 7

  1. 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
  2. 제어판프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.
  3. 인터넷 정보 서비스, World Wide Web Services, 성능 기능을 차례로 확장합니다.
  4. 정적 압축을 설치하려는 경우 동적 압축 및 정적 콘텐츠 압축 을 설치하려면 Http 압축 동적을 선택합니다.
    확장된 성능 기능 노드 및 H T T P 압축 동적이 선택된 스크린샷
  5. 확인을 클릭합니다.

방법

사이트 또는 애플리케이션에 대해 정적 및 동적 압축을 사용하거나 사용하지 않도록 설정하는 방법

  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. 연결 창에서 압축을 사용하도록 설정할 연결, 사이트, 애플리케이션 또는 디렉터리로 이동합니다.

  3. 창에서 압축을 두 번 클릭합니다.
    압축이 선택된 기본 웹 사이트 홈페이지의 스크린샷

  4. 압축 창에서 상자를 검사 정적 또는 동적 압축을 사용하도록 설정하거나 검사 표시를 제거하여 정적 또는 동적 압축을 사용하지 않도록 설정합니다.
    스크린샷은 동적 콘텐츠 압축 사용 및 정적 콘텐츠 압축 상자 사용이 모두 선택된 압축 창을 보여줍니다.

  5. 위의 단계를 완료했으면 작업 창에서 적용을 클릭합니다.

서버에 대해 정적 및 동적 압축을 사용하거나 사용하지 않도록 설정하는 방법

  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. 연결 창에서 서버 이름을 강조 표시합니다.

  3. 서버의 창에서 압축을 두 번 클릭합니다.
    압축이 강조 표시된 서버 홈 창을 보여 주는 스크린샷

  4. 압축 창에서 상자를 검사 정적 또는 동적 압축을 사용하도록 설정하거나 검사 표시를 제거하여 정적 또는 동적 압축을 사용하지 않도록 설정합니다.
    동적 콘텐츠 압축 사용 및 정적 콘텐츠 압축 사용이 선택된 두 상자를 모두 보여 주는 압축 페이지의 스크린샷.

  5. 위의 단계를 완료했으면 작업 창에서 적용을 클릭합니다.

staticCompressionIgnoreHitFrequency를 구성하는 방법

  1. IIS(인터넷 정보 서비스) 관리자를 엽니다.

    • Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows 8.1 사용하는 경우:

      • Windows 키를 누른 채로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 서버를 선택한 다음 구성 편집기를 두 번 클릭합니다.

  3. 구성 편집기에서 섹션에서 system.webServer를 선택한 다음, httpCompression을 선택합니다.

  4. staticCompressionIgnoreHitFrequency의 경우 를 입력 True 하여 특정 기간 내에 특정 횟수에 도달한 경우에만 정적 파일이 압축되는 동작을 사용하지 않도록 설정하거나 를 입력 False 하여 동작을 사용하도록 설정합니다.
    스크린샷은 정적 압축 적중 빈도 무시 옵션에 대해 True가 입력된 구성 편집기 페이지를 보여줍니다.

  5. 작업 창에서 적용을 클릭합니다.

구성

특성

attribute Description
cacheControlHeader 선택적 문자열 특성입니다.

IIS가 HTTP Expires 헤더를 재정의하는 Cache-Control 헤더에 추가하는 지시문을 지정합니다. 이 특성은 이전 클라이언트 및 프록시 서버가 압축된 파일을 캐시하려고 시도하지 않도록 합니다. 이 설정을 사용하려면 sendCacheHeaders 특성을 true로 설정해야 합니다. 이 속성에 대한 변경 내용이 적용되기 전에 WWW 서비스를 다시 시작해야 합니다.

기본값은 max-age=86400입니다.
directory 선택적 문자열 특성입니다.

압축된 버전의 정적 파일이 일시적으로 저장되고 캐시되는 디렉터리를 지정합니다.

참고: IIS 6.0에서 IIS 임시 압축 파일의 기본 디렉터리 경로는 %windir%\IIS 임시 압축 파일이었습니다.

기본값은 %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files입니다.
doDiskSpaceLimiting 선택적 부울 특성입니다.

디렉터리 특성에 지정된 압축 디렉터리에 저장된 모든 압축 파일이 차지할 수 있는 디스크 공간의 양에 대한 제한이 있는지 여부를 지정합니다.

기본값은 true입니다.
dynamicCompressionBufferLimit 선택적 uint 특성입니다.

클라이언트에 버퍼를 플러시하기 전에 IIS에서 버퍼링할 동적으로 압축된 데이터의 최대 크기를 지정합니다. 이렇게 하면 동적 압축을 수행하는 데 필요한 메모리 양이 줄어듭니다.

참고: 이 특성은 IIS 7.5에 추가되었습니다.

기본값은 65536입니다.
dynamicCompressionDisableCpuUsage 선택적 uint 특성입니다.

동적 압축을 사용하지 않도록 설정할 CPU 사용률의 백분율을 지정합니다.

참고: 이 특성은 동적 압축이 꺼지는 CPU 상한으로 작동합니다. CPU 사용률이 dynamicCompressionEnableCpuUsage 특성에 지정된 값보다 낮으면 동적 압축이 다시 활성화됩니다.

기본값은 90입니다.
dynamicCompressionEnableCpuUsage 선택적 uint 특성입니다.

동적 압축을 사용하도록 설정할 CPU 사용률의 백분율을 지정합니다. 값은 0에서 100 사이여야 합니다. 평균 CPU 사용률은 30초마다 계산됩니다.

참고: 이 특성은 동적 압축이 켜져 있는 아래의 낮은 CPU 제한으로 작동합니다. CPU 사용률이 dynamicCompressionDisableCpuUsage 특성에 지정된 값보다 높으면 동적 압축이 비활성화됩니다.

기본값은 50입니다.
expiresHeader 선택적 문자열 특성입니다.

cacheControlHeader 특성에 지정된 Cache-Control 헤더와 함께 요청된 모든 압축 파일과 함께 전송되는 HTTP Expires 헤더의 콘텐츠를 지정합니다. 이 헤더 조합은 이전 클라이언트와 프록시 서버가 압축된 파일을 캐시하려고 하지 않도록 합니다. 이 설정을 사용하려면 sendCacheHeaders 특성을 true로 설정해야 합니다. 이 속성에 대한 변경 내용이 적용되기 전에 WWW 서비스(World Wide Web Publishing Service)를 다시 시작해야 합니다.

기본값은 Wed, 01 Jan 1997 12:00:00 GMT입니다.
maxDiskSpaceUsage 선택적 uint 특성입니다.

압축된 파일이 압축 디렉터리에서 차지할 수 있는 디스크 공간의 메가바이트 수를 지정합니다. 압축된 파일에서 사용하는 공간이 이 특성 값의 90%를 초과하면 IIS는 90% 사용 수준에 도달할 때까지 가장 최근에 사용한 파일을 삭제합니다.

참고: IIS 6.0에서 이 제한은 바이트로 표현되었습니다. IIS 7에서는 MB 단위로 표현됩니다. IIS 7에서는 애플리케이션 풀당 제한이 적용됩니다.

기본값은 100입니다.
minFileSizeForComp 선택적 uint 특성입니다.

주문형 압축을 사용하기 위해 파일에 포함해야 하는 최소 킬로바이트 수를 지정합니다.

IIS 7.5의 기본값은 입니다 2700. IIS 7.0의 경우 기본값은 입니다 256.
noCompressionForHttp10 선택적 부울 특성입니다.

HTTP 1.0 버전 번호를 포함하는 요청에 대해 압축을 사용하지 않도록 설정할지 여부를 지정합니다.

참고: 일부 HTTP 1.0 클라이언트는 압축된 개체의 캐싱을 올바르게 처리하지 않습니다. 압축된 파일을 압축 해제할 수 없는 클라이언트에 반환하지 않도록 하려면 이 설정을 사용할 수 있습니다.

기본값은 true입니다.
noCompressionForProxies 선택적 부울 특성입니다.

프록시 서버를 통해 들어오는 압축 요청에 대해 HTTP 1.1 응답을 사용하지 않도록 설정할지 여부를 지정합니다.

참고: 일부 HTTP 프록시 서버는 압축된 개체의 캐싱을 올바르게 처리하지 않습니다. 압축된 파일을 압축 해제할 수 없는 프록시 서버로 반환하지 않도록 하려면 이 설정을 사용할 수 있습니다.

기본값은 true입니다.
noCompressionForRange 선택적 부울 특성입니다.

Range 헤더를 포함하는 HTTP 요청에 대해 압축을 사용하지 않도록 설정할지 여부를 지정합니다.

참고: 일부 클라이언트는 범위 요청을 올바르게 처리할 수 없습니다. 압축된 파일을 압축 해제할 수 없는 클라이언트에 반환하지 않도록 하려면 이 설정을 사용할 수 있습니다.

기본값은 true입니다.
sendCacheHeaders 선택적 부울 특성입니다.

cacheControlHeaderexpiresHeader에 구성된 헤더가 압축된 각 응답과 함께 전송되는지 여부를 지정합니다.

기본값은 false입니다.
staticCompressionDisableCpuUsage 선택적 uint 특성입니다.

정적 압축을 사용하지 않도록 설정한 CPU 사용률의 백분율을 지정합니다. 값은 0에서 100 사이여야 합니다. 평균 CPU 사용률은 30초마다 계산됩니다.

참고: 이 속성은 정적 압축이 해제되는 CPU 상한의 역할을 합니다. CPU 사용률이 staticCompressionEnableCpuUsage 특성에 지정된 값보다 낮으면 정적 압축이 다시 활성화됩니다.

기본값은 100입니다.
staticCompressionEnableCpuUsage 선택적 uint 특성입니다.

정적 압축이 사용되는 CPU 사용률의 백분율을 지정합니다. 값은 0에서 100 사이여야 합니다. 평균 CPU 사용률은 30초마다 계산됩니다.

참고: 이 속성은 정적 압축이 켜져 있는 아래의 낮은 CPU 제한으로 작동합니다. CPU 사용률이 staticCompressionDisableCpuUsage 특성에 지정된 값보다 높으면 정적 압축이 비활성화됩니다.

기본값은 50입니다.
staticCompressionIgnoreHitFrequency 선택적 부울 특성입니다.

True이면 일정 기간 내에 특정 횟수에 도달한 경우에만 정적 파일이 압축되는 동작을 사용하지 않도록 설정합니다. 정적 콘텐츠를 항상 낮은 대역폭 사용량으로 압축하려는 상황이 발생할 수 있습니다. 예를 들어 시스템에서 웹 서버와 요청자 간에 에지 캐싱이 있는 부하 분산 장치를 사용하는 경우 항상 정적 콘텐츠를 압축하여 이후 요청이 웹 서버에 도달하지 않기 때문에 압축되지 않은 파일이 에지 서버에 캐시될 수 있습니다.

동작을 사용하지 않도록 설정하지 않으면 10초 동안 적중률이 2회보다 크거나 같으면 정적 콘텐츠가 압축됩니다. 적중률이 낮을수록 콘텐츠가 압축되지 않습니다.

기본값은 False입니다.

자식 요소

요소 Description
scheme 선택적 요소입니다.

IIS가 클라이언트 요청을 압축하는 데 사용하는 압축 체계(Gzip 또는 Deflate)를 지정합니다.
dynamicTypes 선택적 요소입니다.

동적 압축에 대한 구성 설정을 지정합니다.
staticTypes 선택적 요소입니다.

정적 압축에 대한 구성 설정을 지정합니다.

구성 샘플

다음 기본 <httpCompression> 요소는 IIS 7의 ApplicationHost.config 파일에 구성됩니다. 이 구성 섹션에서는 요소를 사용하지 않는 한 기본 구성 설정을 상속합니다 <clear> .

<httpCompression
      directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
   <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
   <dynamicTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="*/*" enabled="false" />
   </dynamicTypes>
   <staticTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="*/*" enabled="false" />
   </staticTypes>
</httpCompression>

샘플 코드

다음 코드 샘플에서는 Office 2003 문서의 MIME 형식을 동적 압축 형식 목록에 추가합니다.

참고

Office 2007 문서는 기본 제공 압축을 사용하므로 IIS에서 압축할 필요가 없습니다.

AppCmd.exe

appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/msword',enabled='True']" /commit:apphost

appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/vnd.ms-powerpoint',enabled='True']" /commit:apphost

appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/vnd.ms-excel',enabled='True']" /commit:apphost

참고

AppCmd.exe 사용하여 이러한 설정을 구성할 때 커밋 매개 변수 apphost 를 로 설정해야 합니다. 그러면 구성 설정이 ApplicationHost.config 파일의 적절한 위치 섹션에 커밋됩니다.

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.GetApplicationHostConfiguration();
         ConfigurationSection httpCompressionSection = config.GetSection("system.webServer/httpCompression");
         ConfigurationElementCollection dynamicTypesCollection = httpCompressionSection.GetCollection("dynamicTypes");

         ConfigurationElement addElement = dynamicTypesCollection.CreateElement("add");
         addElement["mimeType"] = @"application/msword";
         addElement["enabled"] = true;
         dynamicTypesCollection.Add(addElement);

         ConfigurationElement addElement1 = dynamicTypesCollection.CreateElement("add");
         addElement1["mimeType"] = @"application/vnd.ms-powerpoint";
         addElement1["enabled"] = true;
         dynamicTypesCollection.Add(addElement1);

         ConfigurationElement addElement2 = dynamicTypesCollection.CreateElement("add");
         addElement2["mimeType"] = @"application/vnd.ms-excel";
         addElement2["enabled"] = true;
         dynamicTypesCollection.Add(addElement2);

         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.GetApplicationHostConfiguration
      Dim httpCompressionSection As ConfigurationSection = config.GetSection("system.webServer/httpCompression")
      Dim dynamicTypesCollection As ConfigurationElementCollection = httpCompressionSection.GetCollection("dynamicTypes")

      Dim addElement As ConfigurationElement = dynamicTypesCollection.CreateElement("add")
      addElement("mimeType") = "application/msword"
      addElement("enabled") = True
      dynamicTypesCollection.Add(addElement)

      Dim addElement1 As ConfigurationElement = dynamicTypesCollection.CreateElement("add")
      addElement1("mimeType") = "application/vnd.ms-powerpoint"
      addElement1("enabled") = True
      dynamicTypesCollection.Add(addElement1)

      Dim addElement2 As ConfigurationElement = dynamicTypesCollection.CreateElement("add")
      addElement2("mimeType") = "application/vnd.ms-excel"
      addElement2("enabled") = True
      dynamicTypesCollection.Add(addElement2)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var httpCompressionSection = adminManager.GetAdminSection("system.webServer/httpCompression", "MACHINE/WEBROOT/APPHOST");
var dynamicTypesCollection = httpCompressionSection.ChildElements.Item("dynamicTypes").Collection;

var addElement = dynamicTypesCollection.CreateNewElement("add");
addElement.Properties.Item("mimeType").Value = "application/msword";
addElement.Properties.Item("enabled").Value = true;
dynamicTypesCollection.AddElement(addElement);

var addElement1 = dynamicTypesCollection.CreateNewElement("add");
addElement1.Properties.Item("mimeType").Value = "application/vnd.ms-powerpoint";
addElement1.Properties.Item("enabled").Value = true;
dynamicTypesCollection.AddElement(addElement1);

var addElement2 = dynamicTypesCollection.CreateNewElement("add");
addElement2.Properties.Item("mimeType").Value = "application/vnd.ms-excel";
addElement2.Properties.Item("enabled").Value = true;
dynamicTypesCollection.AddElement(addElement2);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set httpCompressionSection = adminManager.GetAdminSection("system.webServer/httpCompression", "MACHINE/WEBROOT/APPHOST")
Set dynamicTypesCollection = httpCompressionSection.ChildElements.Item("dynamicTypes").Collection

Set addElement = dynamicTypesCollection.CreateNewElement("add")
addElement.Properties.Item("mimeType").Value = "application/msword"
addElement.Properties.Item("enabled").Value = True
dynamicTypesCollection.AddElement(addElement)

Set addElement1 = dynamicTypesCollection.CreateNewElement("add")
addElement1.Properties.Item("mimeType").Value = "application/vnd.ms-powerpoint"
addElement1.Properties.Item("enabled").Value = True
dynamicTypesCollection.AddElement(addElement1)

Set addElement2 = dynamicTypesCollection.CreateNewElement("add")
addElement2.Properties.Item("mimeType").Value = "application/vnd.ms-excel"
addElement2.Properties.Item("enabled").Value = True
dynamicTypesCollection.AddElement(addElement2)

adminManager.CommitChanges()

다음 코드 샘플에서는 Office 2003 문서의 MIME 형식을 정적 압축 형식 목록에 추가합니다.

(> [! 참고]

Office 2007 문서는 기본 제공 압축을 사용하므로 IIS에서 압축할 필요가 없습니다.)

AppCmd.exe

appcmd.exe set config -section:system.webServer/httpCompression /+"staticTypes.[mimeType='application/msword',enabled='True']" /commit:apphost

appcmd.exe set config -section:system.webServer/httpCompression /+"staticTypes.[mimeType='application/vnd.ms-powerpoint',enabled='True']" /commit:apphost

appcmd.exe set config -section:system.webServer/httpCompression /+"staticTypes.[mimeType='application/vnd.ms-excel',enabled='True']" /commit:apphost

참고

AppCmd.exe 사용하여 이러한 설정을 구성할 때 커밋 매개 변수 apphost 를 로 설정해야 합니다. 그러면 구성 설정이 ApplicationHost.config 파일의 적절한 위치 섹션에 커밋됩니다.

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.GetApplicationHostConfiguration();
         ConfigurationSection httpCompressionSection = config.GetSection("system.webServer/httpCompression");
         ConfigurationElementCollection staticTypesCollection = httpCompressionSection.GetCollection("staticTypes");

         ConfigurationElement addElement = staticTypesCollection.CreateElement("add");
         addElement["mimeType"] = @"application/msword";
         addElement["enabled"] = true;
         staticTypesCollection.Add(addElement);

         ConfigurationElement addElement1 = staticTypesCollection.CreateElement("add");
         addElement1["mimeType"] = @"application/vnd.ms-powerpoint";
         addElement1["enabled"] = true;
         staticTypesCollection.Add(addElement1);

         ConfigurationElement addElement2 = staticTypesCollection.CreateElement("add");
         addElement2["mimeType"] = @"application/vnd.ms-excel";
         addElement2["enabled"] = true;
         staticTypesCollection.Add(addElement2);

         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.GetApplicationHostConfiguration
      Dim httpCompressionSection As ConfigurationSection = config.GetSection("system.webServer/httpCompression")
      Dim staticTypesCollection As ConfigurationElementCollection = httpCompressionSection.GetCollection("staticTypes")

      Dim addElement As ConfigurationElement = staticTypesCollection.CreateElement("add")
      addElement("mimeType") = "application/msword"
      addElement("enabled") = True
      staticTypesCollection.Add(addElement)

      Dim addElement1 As ConfigurationElement = staticTypesCollection.CreateElement("add")
      addElement1("mimeType") = "application/vnd.ms-powerpoint"
      addElement1("enabled") = True
      staticTypesCollection.Add(addElement1)

      Dim addElement2 As ConfigurationElement = staticTypesCollection.CreateElement("add")
      addElement2("mimeType") = "application/vnd.ms-excel"
      addElement2("enabled") = True
      staticTypesCollection.Add(addElement2)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var httpCompressionSection = adminManager.GetAdminSection("system.webServer/httpCompression", "MACHINE/WEBROOT/APPHOST");
var staticTypesCollection = httpCompressionSection.ChildElements.Item("staticTypes").Collection;

var addElement = staticTypesCollection.CreateNewElement("add");
addElement.Properties.Item("mimeType").Value = "application/msword";
addElement.Properties.Item("enabled").Value = true;
staticTypesCollection.AddElement(addElement);

var addElement1 = staticTypesCollection.CreateNewElement("add");
addElement1.Properties.Item("mimeType").Value = "application/vnd.ms-powerpoint";
addElement1.Properties.Item("enabled").Value = true;
staticTypesCollection.AddElement(addElement1);

var addElement2 = staticTypesCollection.CreateNewElement("add");
addElement2.Properties.Item("mimeType").Value = "application/vnd.ms-excel";
addElement2.Properties.Item("enabled").Value = true;
staticTypesCollection.AddElement(addElement2);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set httpCompressionSection = adminManager.GetAdminSection("system.webServer/httpCompression", "MACHINE/WEBROOT/APPHOST")
Set staticTypesCollection = httpCompressionSection.ChildElements.Item("staticTypes").Collection

Set addElement = staticTypesCollection.CreateNewElement("add")
addElement.Properties.Item("mimeType").Value = "application/msword"
addElement.Properties.Item("enabled").Value = True
staticTypesCollection.AddElement(addElement)

Set addElement1 = staticTypesCollection.CreateNewElement("add")
addElement1.Properties.Item("mimeType").Value = "application/vnd.ms-powerpoint"
addElement1.Properties.Item("enabled").Value = True
staticTypesCollection.AddElement(addElement1)

Set addElement2 = staticTypesCollection.CreateNewElement("add")
addElement2.Properties.Item("mimeType").Value = "application/vnd.ms-excel"
addElement2.Properties.Item("enabled").Value = True
staticTypesCollection.AddElement(addElement2)

adminManager.CommitChanges()