【Gzip压缩】网页启用Gzip压缩 提高浏览速度

云码酷  于 2018-4-26 21:39:03 |只看大图 回帖奖励 |阅读模式
1 2898

马上注册,自学更多教程,下载更多资源。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
  Gzip压缩我很早已经就启用了,不过从未与大家分享过。近期由于备案问题,临时更换服务器,结果忘了启用Gzip压缩,周末利用空余时间启用了Gzip压缩,并把全部过程记录下来,与大家分享。
  启用Gzip压缩的好处

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

云码酷 【Gzip压缩】网页启用Gzip压缩 提高浏览速度 压缩,网页,启用,提高,浏览 SEO自学 033440i5clfy5jjj9g0ysc


  网页启用Gzip压缩 提高浏览速度
  Gzip压缩效率非常高,通常可以达到70%的压缩率,也就是说,如果你的网页有30K,压缩之后就变成了9K左右。
  第一步:打开IIS,启用HTTP压缩服务

云码酷 【Gzip压缩】网页启用Gzip压缩 提高浏览速度 压缩,网页,启用,提高,浏览 SEO自学 033440bj1cl2e5mh41zahe


  网页启用Gzip压缩 提高浏览速度
  右击“网站”->“属性”,选择“服务”。在“HTTP压缩”框中选中“压缩应用程序文件”和“ 压缩静态文件”,按需要设置“临时目录”和“临时目录的最大限制”;
  第二步:启用web服务

云码酷 【Gzip压缩】网页启用Gzip压缩 提高浏览速度 压缩,网页,启用,提高,浏览 SEO自学 033440lccdmjdpj7c982d9


  网页启用Gzip压缩 提高浏览速度
  第三步:修改MetaBase.xml
  开始 > 运行中输入 c:\windows\system32\inetsrv,找到 MeteBase.xml,先备份,在修改。(有的服务器不需要修改此文件便可以使用)
  搜索 Location ="/LM/W3SVC/Filters/Compression/gzip"
  仔细核对下代码:
  <IIsCompressionScheme Location =&quot;/LM/W3SVC/Filters/Compression/deflate&quot;
  HcCompressionDll=&quot;%windir%\system32\inetsrv\gzip.dll&quot;
  HcCreateFlags=&quot;0&quot;
  HcDoDynamicCompression=&quot;TRUE&quot;
  HcDoOnDemandCompression=&quot;TRUE&quot;
  HcDoStaticCompression=&quot;FALSE&quot;
  HcDynamicCompressionLevel=&quot;0&quot;
  HcFileExtensions=&quot;htm
  html
  txt&quot;
  HcOnDemandCompLevel=&quot;10&quot;
  HcPriority=&quot;1&quot;
  HcScriptFileExtensions=&quot;asp
  dll
  exe&quot;
  >
  </IIsCompressionScheme>
  <IIsCompressionScheme Location =&quot;/LM/W3SVC/Filters/Compression/gzip&quot;
  HcCompressionDll=&quot;%windir%\system32\inetsrv\gzip.dll&quot;
  HcCreateFlags=&quot;1&quot;
  HcDoDynamicCompression=&quot;TRUE&quot;
  HcDoOnDemandCompression=&quot;TRUE&quot;
  HcDoStaticCompression=&quot;TRUE&quot;
  HcDynamicCompressionLevel=&quot;0&quot;
  HcFileExtensions=&quot;htm
  html
  txt&quot;
  HcOnDemandCompLevel=&quot;10&quot;
  HcPriority=&quot;1&quot;
  HcScriptFileExtensions=&quot;asp
  dll
  exe&quot;
  >
  </IIsCompressionScheme>
  替换成:
  <IIsCompressionScheme Location =&quot;/LM/W3SVC/Filters/Compression/gzip&quot;
  HcCompressionDll=&quot;%windir%\system32\inetsrv\gzip.dll&quot;
  HcCreateFlags=&quot;1&quot;
  HcDoDynamicCompression=&quot;TRUE&quot;
  HcDoOnDemandCompression=&quot;TRUE&quot;
  HcDoStaticCompression=&quot;TRUE&quot;
  HcDynamicCompressionLevel=&quot;10&quot;
  HcFileExtensions=&quot;html
  css
  js
  htm
  xml
  txt&quot;
  HcOnDemandCompLevel=&quot;10&quot;
  HcPriority=&quot;1&quot;
  HcScriptFileExtensions=&quot;php
  dll&quot;
  >
  </IIsCompressionScheme>
  <IIsCompressionScheme Location =&quot;/LM/W3SVC/Filters/Compression/deflate&quot;
  HcCompressionDll=&quot;%windir%\system32\inetsrv\gzip.dll&quot;
  HcCreateFlags=&quot;2&quot;
  HcDoDynamicCompression=&quot;TRUE&quot;
  HcDoOnDemandCompression=&quot;TRUE&quot;
  HcDoStaticCompression=&quot;TRUE&quot;
  HcDynamicCompressionLevel=&quot;10&quot;
  HcFileExtensions=&quot;html
  css
  js
  htm
  xml
  txt&quot;
  HcOnDemandCompLevel=&quot;10&quot;
  HcPriority=&quot;1&quot;
  HcScriptFileExtensions=&quot;php
  dll&quot;
  >
  </IIsCompressionScheme>
  修改好后,在服务中停止IIS Admin Service 服务。

云码酷 【Gzip压缩】网页启用Gzip压缩 提高浏览速度 压缩,网页,启用,提高,浏览 SEO自学 033441se59afrf48t7tzfj


  网页启用Gzip压缩 提高浏览速度
  然后在保存MeteBase.xml,保存好后再启动IIS。这样Gzip压缩就启用成功了。
  最后,测试Gzip压缩是否成功,可以到站长工具http://tool.chinaz.com/Gzips/进行检测。
  提示:
  本文仅针对windows的IIS服务器上演示的,VPS主机、独立服务器均可以实现,虚拟主机用户需要咨询空间商(一般虚拟主机都启用了Gzip)如果你的站在启用Gzip压缩时遇到了困难,可在此跟帖评论与交流,我会竭尽全力为大家解答。
  文章来源:卢松松的博客,转载请注明出处。


上一篇:【如何301重定向】windows系列虚拟主机IIS 301重定向方法
下一篇:【Gzip压缩】网页如何开启Gzip压缩

云码酷 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
2、本站所有主题由该帖子作者发表,该帖子作者与云码酷享有帖子相关版权
3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和云码酷的同意
4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
7、云码酷管理员和版主有权不事先通知发贴者而删除本文

| 0 人收藏
回复

使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    1

    主题

    209

    帖子

    210

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    210
    发表于 2018-4-27 06:02:48 | 只看该作者
    沙发
    为毛老子总也抢不到沙发?!!
    回复 支持 反对

    使用道具 举报

    • 售后服务
    • 关注我们
    • 社区新手

    申请友链|Archiver|手机版|小黑屋|云码酷 ( 京ICP备13037810号 )

    Powered by Discuz! X3.2  © 2001-2022 云码酷