your programing

IIS 7.5에서 GZip 압축이 작동하지 않습니다.

lovepro 2020. 12. 30. 19:48
반응형

IIS 7.5에서 GZip 압축이 작동하지 않습니다.


IIS에서 정적 파일에 대해 GZip 압축을 지원하려고하지만 (기본적으로 활성화되어야하지만 그렇지 않음) 지금까지 작동하지 않습니다. 다음은 <system.webServer>웹앱의 web.config 파일에있는 노드 아래 섹션입니다 .

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

<urlCompression doStaticCompression="true" />

나는 구글 크롬으로 그것을 시도했다. 다음은 요청 헤더입니다.

수락 : text / html, application / xhtml + xml, application / xml; q = 0.9, / ; q = 0.8

Accept-Charset : ISO-8859-1, utf-8; q = 0.7, *; q = 0.3

Accept-Encoding : gzip, deflate, sdch

Accept-Language : en-US, en; q = 0.8

캐시 제어 : 캐시 없음

연결 : 연결 유지

호스트 : my-website-url

Pragma : no-cache

User-Agent : Mozilla / 5.0 (Windows NT 6.0) AppleWebKit / 534.30 (Gecko와 같은 KHTML) Chrome / 12.0.742.122 Safari / 534.30

이들은 응답 헤더입니다.

Accept-Ranges : 바이트

콘텐츠 길이 : 232651

콘텐츠 유형 : application / x-javascript

날짜 : 2011 년 8 월 4 일 목요일 08:58:19 GMT

ETag : "a69135734a50cc1 : 0"

최종 수정 : 2011 년 8 월 1 일 월요일 12:56:37 GMT

서버 : Microsoft-IIS / 7.5

X-Powered-By : ASP.NET

applicationHost.config 파일을 확인하고 아래와 같은 노드를 찾았습니다.

----

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

----

<section name="urlCompression" overrideModeDefault="Allow" />

----

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

----

<urlCompression />

내가 여기서 무엇을 놓치고 있습니까?


많은 검색 끝에 마침내 IIS 7.5에서 압축이 작동하는 것을 발견했습니다. 우선 IIS는 파일이 충분히 자주로드되지 않는 한 파일을 압축하지 않습니다. 그러면 "IIS가 충분히 자주 고려하는 것은 무엇입니까?"라는 질문이 나타납니다. 음, 기본값은 10 초마다 2 번입니다. 이런!

이 설정은 web.config에서 변경할 수 있지만 먼저 applicationHost.config에서 섹션의 잠금을 해제해야합니다. 다음은 명령입니다.

먼저 섹션을 잠금 해제하십시오.

C : \ Windows \ System32 \ inetsrv \ appcmd.exe 구성 잠금 해제 /section:system.webServer/serverRuntime

Unlocked section "system.webServer/serverRuntime" at configuration path "MACHINE/WEBROOT/APPHOST".

Now that is done, edit the web.config file and add the serverRuntime element:

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
      <serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="10:00:00" />
...

In this case, I set it to hit the file once in a 10 hour period. You can adjust the values as necessary. Here is the document that explains the serverRuntime element:

http://www.iis.net/configreference/system.webserver/serverruntime

I hope this helps get your compression working as well.

Note: you can also set the serverRuntime element up in the applicationHost.config file, but I chose to change it in the web.config because we have a number of servers and farms with various sites, and it is easier for me to control it from this level of granularity.


One thing to keep in mind is that the first hit usually is returned uncompressed immediately, but spins up a thread to compress the file in the background in order to service the response with compression for future requests.

Also, have you tried using a different client (e.g. IE)?


Make sure you install Dynamic Compression on the server. Add/Remove Features under IIS.


Took me a while to figure this out too. Setting the frequentHitThreshold attribute to 1 on the system.webServer/serverRuntime node in the applicationHost.config file should do the trick, as documented at http://www.iis.net/ConfigReference/system.webServer/serverRuntime.

You can do this by executing the following command as an administrator:

%windir%\system32\inetsrv\appcmd set config /section:serverRuntime /frequentHitThreshold:1 /commit:apphost

A word of warning - the "frequent hit" concept does not seem specific to compression. I have no idea whether there are other consequences as a result of setting this!


"system.webServer configuration does not allows httpCompression at the Web site level" https://serverfault.com/questions/125139/iis7-dynamic-compression-not-success-reason-12

Why do you use configuration files? Just try to create new dummy web site with some txt file more than 2700 bytes. Also you may try to install dynamic compression module and turn it on for server ant this dummy site.


One thing we found was that our Azure website was hitting it's max CPU usage due to having a high resource WebJob running. We had tried all the settings above and nothing worked. Then we checked the Resource CPU usage and found it was 80%+. At 80% CPU load the gzip stops working!

ReferenceURL : https://stackoverflow.com/questions/6938713/gzip-compression-on-iis-7-5-is-not-working

반응형