一般人都是介绍linux下开启网页Gzip功能,但是在windows下怎么开启网页Gzip呢,下面便宜吧转了一篇文章给大家参考。

Windows服务器IIS下开启网页Gzip压缩功能图文教程

 

启用Gzip压缩的好处

它的好处显而易见,提高网页浏览速度,无论是之前说的精简代码、压缩图片都不如启用Gzip来的实在。下图为启用Gzip后的效果。

Windows服务器IIS下开启网页Gzip压缩功能图文教程

Gzip压缩效率非常高,通常可以达到70%的压缩率,也就是说,如果你的网页有30K,压缩之后就变成了9K左右。

第一步:打开IIS,启用HTTP压缩服务

Windows服务器IIS下开启网页Gzip压缩功能图文教程

右击“网站”->“属性”,选择“服务”。在“HTTP压缩”框中选中“压缩应用程序文件”和“ 压缩静态文件”,按需要设置“临时目录”和“临时目录的最大限制”;

第二步:启用web服务

Windows服务器IIS下开启网页Gzip压缩功能图文教程

第三步:修改MetaBase.xml

开始 > 运行中输入 c:\windows\system32\inetsrv,找到 MeteBase.xml,先备份,在修改。(有的服务器不需要修改此文件便可以使用)

搜索 Location ="/LM/W3SVC/Filters/Compression/gzip"

仔细核对下代码:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="FALSE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
< /IIsCompressionScheme>
< IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
< /IIsCompressionScheme>

替换成:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="html
css
js
htm
xml
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="php
dll"
>
< /IIsCompressionScheme>
< IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="2"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="html
css
js
htm
xml
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="php
dll"
>
< /IIsCompressionScheme>

修改好后,在服务中停止IIS Admin Service 服务。

Windows服务器IIS下开启网页Gzip压缩功能图文教程

然后在保存MeteBase.xml,保存好后再启动IIS。这样Gzip压缩就启用成功了。

最后,测试Gzip压缩是否成功,可以到站长工具http://tool.chinaz.com/Gzips/进行检测。

版权所有:站元素小博客 => 《Windows服务器IIS下开启网页Gzip压缩功能图文教程》

本文地址:http://www.zysgp.net/blog/?post=37

除非注明,文章均为 站元素小博客 原创,欢迎转载!转载请注明本文地址,谢谢。