IIS 7.5忽略web.config中的HttpCompression设置

我试图为MIMEtypes的application/json启用dynamic压缩

在applicationHost.config中,我做了以下更改:

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

我也尝试用以下命令解锁该部分:

 appcmd unlock config /section:system.webserver/httpcompression 

我的web.config设置(与applicationHost.config相同,但有其他mimetype):

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

但是这个回应并没有被压缩。 我知道设置是正确的,因为它的工作如果我直接添加到applicationHost.config mimetype。

我启用了失败的请求追踪,并没有产生错误。

尝试添加MIMEtypes:

  <add mimeType="application/json; charset=utf-8" enabled="true" /> 

我有同样的问题,即试图让IIS(在我的情况下,IIS 10)gzip application/json但已经发现了一个解决方法。

我已经尝试编辑ApplicationHost.config以及web.config没有运气。 IIS只是忽略.json数据的任何压缩设置。 它会很高兴地gzip你告诉它压缩虽然任何其他mimetype。 所以我改变了mimetype到text/json在web.config现在我有gzip的回应:

 <system.webServer> <staticContent> <remove fileExtension=".json" /> <mimeMap fileExtension=".json" mimeType="text/json" /> </staticContent> <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/> <dynamicTypes> <add mimeType="text/json" enabled="true"/> </dynamicTypes> <staticTypes> <add mimeType="text/json" enabled="true"/> </staticTypes> </httpCompression> <urlCompression doStaticCompression="true" doDynamicCompression="true"/> </system.webServer> 

当然,这可能会打破其他的东西 – 因为现在你的回应有Content-Type:text/json