IIS 开启Gzip压缩功能
1、配置windows功能
勾选 动态内容压缩,静态内容压缩 如下图
2、IIS配置
进入IIS面板->选择压缩->勾选 动态内容压缩,静态内容压缩 如下图
3、配置压缩首选项
进入C:\Windows\System32\inetsrv\config
目录,编辑applicationhost.config
文件
源文件中不包含
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json;charset=utf-8" enabled="true" />
修改后文件内容
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json;charset=utf-8" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json;charset=utf-8" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
4、重启IIS
通过cmd 管理员权限执行 iisreset重启服务