使用IIS内置压缩功能,增加网站访问速度

【网上购物论坛】-IT泡吧![Www.itpob.Cn]网上购物社区! - Powered by Discuz!
http://www.itpob.cn/index.php

 

 

HTTP 压缩是在Web服务器和浏览器间传输压缩文本内容的方法。HTTP压缩采用通用的压缩算法如gzip等压缩HTML、JavaScript或CSS文件。压缩的最大好处就是降低了网络传输的数据量,从而提高客户端浏览器的访问速度。当然,同时也会增加一点点服务器的负担。Gzip是比较常见的一种HTTP 压缩算法。

  默认的IIS中是有GZIP.dll组件的,我们只要开启即可.操作步骤如下:

  1.开启HTTP压缩功能

    在IIS中右键网站属性->服务选项卡->选中<压缩应用程序文件><压缩静态文件>两个选项.如图

  使用IIS内置压缩功能,增加网站访问速度

  

 

  2.在Web服务扩展中增加一个新扩展

  右键Web服务扩展->增加一个新的Web服务扩展->要求的文件C:\WINDOWS\system32\inetsrv\gzip.dll ->设置扩展状态为允许.如图

  使用IIS内置压缩功能,增加网站访问速度

  

 

  3.修改IIS配置文件 (注意: 一定要先备份MetaBase.xml文件)

  1).打开C:\Windows\System32\inetsrv\MetaBase.xml文件.

  2).使用ctrl+f查找 Location ="/LM/W3SVC/Filters/Compression/gzip"与      Location ="/LM/W3SVC/Filters/Compression/deflate"

  3).将两个节点的配置修改为如下配置

  

使用IIS内置压缩功能,增加网站访问速度使用IIS内置压缩功能,增加网站访问速度代码

<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate" HcCompressionDll="%windir%\system32\inetsrv\gzip.dll" HcCreateFlags="0" HcDoDynamicCompression="TRUE" HcDoOnDemandCompression="TRUE" HcDoStaticCompression="true" HcDynamicCompressionLevel="9" HcFileExtensions="htm html txt js css swf xml" HcOnDemandCompLevel="9" HcPriority="1" HcScriptFileExtensions="asp aspx 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="9" HcFileExtensions="htm html txt js css swf xml" HcOnDemandCompLevel="9" HcPriority="1" HcScriptFileExtensions="asp aspx dll exe" > </IIsCompressionScheme>

其中HcFileExtensions中是需要静态压缩的后缀,你也可以添加doc,xsl等文件内容

HcScriptFileExtensions 则是动态压缩的后缀

 

  4.修改完毕后,保存文件,重启IIS即可.(如果无法保存,代表IIS正在使用中,可以先关闭IIS服务)

 

 

 

另外GZIP检测地址为:http://tool.chinaz.com/Gzips/

 

可以看出博客园也是进行过GZIP加速的:

使用IIS内置压缩功能,增加网站访问速度



没有目标的人都只在帮有目标的人完成目标。

<script type="text/javascript"></script>