zoukankan      html  css  js  c++  java
  • 使用mod_deflate模块压缩页面优化传输速度

    在HTTPD主配置文件中添加如下,并确保deflate模块是启用的

    #vim /etc/httpd/conf/httpd.conf

           SetOutputFilter DEFLATE//调用一个叫DEFLATE输出过滤器

           # mod_deflate configuration

                 

           # Restrict compression to these MIME types

           AddOutputFilterByType DEFLATE text/plain

           AddOutputFilterByType DEFLATE text/html

           AddOutputFilterByType DEFLATE application/xhtml+xml

           AddOutputFilterByType DEFLATE text/xml

           AddOutputFilterByType DEFLATE application/xml

           AddOutputFilterByType DEFLATE application/x-javascript

           AddOutputFilterByType DEFLATE text/javascript

           AddOutputFilterByType DEFLATE text/css

                   

           # Level of compression (Highest 9 - Lowest 1)

           DeflateCompressionLevel 9//过滤时压缩比

                          

           # Netscape 4.x has some problems.

           BrowserMatch ^Mozilla/4 gzip-only-text/html

                          

           # Netscape 4.06-4.08 have some more problems

           BrowserMatch ^Mozilla/4.0[678] no-gzip

                          

           # MSIE masquerades as Netscape, but it is fine

           BrowserMatch MSI[E] !no-gzip !gzip-only-text/html

    然后#service httpd reload

    #cp /etc/rc.d/rc.sysinit /vhosts/web1/htdocs/test.html     //vhosts/web1/htdocs这个目录是提前创建的

    #curl -I http://192.160.108.160/test.html  //查看响应报文的首部

    #curl -I --compressed http://192.160.108.160/test.html

    可以看出调用的压缩功能以后,响应报文首部的内容长度是原来的三分之一

  • 相关阅读:
    SQL Server将一列的多行内容拼接成一行的问题讨论
    SQL 获取 IDENTITY 三种方法 SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY的区别
    构建高性能服务(二)
    乐观锁解决高并发
    c#问答篇:对象与引用变量-----初学者的困惑
    vs调试 本地IIS
    【转】android adb常用指令
    【转】使用 JMeter 完成常用的压力测试
    【转】利用 Apache JMeter 测试 WebSphere 性能
    【转】用JMeter来测试Tomcat的性能
  • 原文地址:https://www.cnblogs.com/hanshanxiaoheshang/p/9139431.html
Copyright © 2011-2022 走看看