我似乎无法为我的ASP.NET 4应用程序启用GZIP压缩。只有javascript文件似乎被压缩。
I just can't seem to get GZIP compression enabled for my ASP.NET 4 application. Only javascript files seem to get compressed. The page, css and others dont get compressed.
未压缩的CSS文件的响应标题为:
The response header of a not compressed CSS file is:
Content-Type text/css Last-Modified Mon, 09 Aug 2010 20:10:34 GMT Accept-Ranges bytes Etag "5d71bdecfe37cb1:0" Server Microsoft-IIS/7.5 Date Sat, 28 Aug 2010 14:33:56 GMT Content-Length 3364对于被压缩的Javascript文件(scriptresource.axd):
And for a Javascript file that gets compressed (scriptresource.axd):
Cache-Control public Content-Type application/x-javascript Content-Encoding gzip Expires Sun, 28 Aug 2011 14:33:50 GMT Last-Modified Sat, 28 Aug 2010 14:33:50 GMT Server Microsoft-IIS/7.5 Date Sat, 28 Aug 2010 14:33:56 GMT Content-Length 478在applicationHost.config中:
In applicationHost.config:
<httpCompression sendCacheHeaders="false" directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForRange="true"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> <staticTypes> </staticTypes> <dynamicTypes> </dynamicTypes> </httpCompression>在应用程序web.config中:
And in the app web.config:
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" /> <httpCompression noCompressionForRange="false" noCompressionForHttp10="false" noCompressionForProxies="false" > <dynamicTypes> <add mimeType="text/css" enabled="true" /> </dynamicTypes> <staticTypes> <add mimeType="text/css" enabled="true" /> </staticTypes> </httpCompression>任何人都可以告诉我我缺少什么设置?
Can anybody tell me what setting I am missing?
推荐答案我发现了什么问题...在打开或关闭Windows功能 - > WWW - >性能特性,动态压缩未启用(很愚蠢)。
I found out what the problem was... In Turn Windows features on or off -> WWW -> Performance features, the static & dynamic compression was not enabled (pretty stupid).
Javascript被压缩的原因可能是因为ScriptResource.axd实现了自定义gzip编码。
The reason the Javascript was compressed is probably because ScriptResource.axd implements a custom gzip encoding.
更多推荐
IIS 7.5 ASP.NET
发布评论