GZip压缩的COM pression在IIS 7.5中无法正常工作

问题描述:

我想支持gzip COM pression我的IIS下的静态文件(这应该是默认启用,但没有),但没有工作至今。这是在部分< system.webServer> Web应用程序的Web.config文件中的节点;

I am trying to support GZip compression for my static files under IIS (which should be enabled by default but not) but not working so far. Here is the the section under <system.webServer> node inside the web.config file of the web app;

<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" />

我试图与谷歌Chrome浏览器。下面是请求头;

I tried it with Google Chrome. Here are the Request Headers;

接受:text / html的,是application / xhtml + xml的,应用程序/ XML; Q = 0.9, / 的; Q = 0.8

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

接收字符集:ISO-8859-1,UTF-8,Q = 0.7,*; Q = 0.3

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

接受编码:gzip,紧缩,SDCH

Accept-Encoding:gzip,deflate,sdch

接受语言:EN-US,EN; Q = 0.8

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

的Cache-Control:no-cache的

Cache-Control:no-cache

连接:保持活动

主持人:我-网站网址

杂注:无缓存

的User-Agent:Mozilla的/ 5.0(Windows NT的6.0)为AppleWebKit / 534.30(KHTML,   像壁虎)的Chrome / Safari浏览器12.0.742.122 / 534.30

User-Agent:Mozilla/5.0 (Windows NT 6.0) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30

这些都是响应头;

接受-范围:字节

内容长度:232651

Content-Length:232651

内容类型:应用程序/ x-j​​avascript的

Content-Type:application/x-javascript

日期:星期四,2011年8月4日8时58分19秒GMT

Date:Thu, 04 Aug 2011 08:58:19 GMT

ETag的:a69135734a50cc1:0

ETag:"a69135734a50cc1:0"

的Last-Modified:星期一,2011年8月1日十二时56分37秒GMT

Last-Modified:Mon, 01 Aug 2011 12:56:37 GMT

服务器:Microsoft-IIS / 7.5

Server:Microsoft-IIS/7.5

X-Powered-By中:ASP.NET

X-Powered-By:ASP.NET

我检查applicationHost.config文件,发现类似下面的一些节点;

I check the applicationHost.config file and found some nodes like below;

----

<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 />

我是什么在这里失踪?

What am I missing here?

有一点要记住的是,先打通常返回uncom $ P $立即pssed,但旋转了一个线程COM preSS的在后台以服务与COM pression为将来的请求响应文件。

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.

另外,你有没有尝试使用不同的客户端(如IE)?

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