我一直在玩"C:\Windows\System32\inetsrv\config"目录中的"applicationHost.config"文件,到目前为止还不错,我只想确定一下:
<httpCompression directory="%SystemDrive%inetpubtempIIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%system32inetsrvgzip.dll" />
<staticTypes>
......
</staticTypes>
<dynamicTypes>
......
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
如您所见,我添加了<add mimeType="application/json" enabled="true" />
行。这会确保只有使用jquery的动态Ajax调用才会被压缩吗?我正在使用调用我的ASP.NET页面方法
$.ajax({
type: "POST",
url: 'someur.aspx/someMethod',
contentType: "application/json; charset=utf-8",
.....
我说得对吗?
您需要添加2种内容类型来启用JSON的动态压缩:
<httpCompression directory="%SystemDrive%inetpubtempIIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%system32inetsrvgzip.dll" />
<dynamicTypes>
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
<!-- all other MIME type come here -->
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
</httpCompression>