win2003中Apache开启gzip功能

    xiaoxiao2021-11-30  20

    一直觉得网站访问速度很慢,打开0.6秒,打开GZIP后打开只要0.1秒,非常不错!

     

     

    HTTP 压缩可以大大提高浏览网站的速度,它的原理是,在客户端请求网页后,从服务器端将网页文件压缩,再下载到客户端,由客户端的浏览器负责解压缩并浏览。相对于普通的浏览过程HTML ,CSS,Javascript , Text ,它可以节省40%左右的流量。更为重要的是,它可以对动态生成的,包括CGI、PHP , JSP , ASP , Servlet,SHTML等输出的网页也能进行压缩,压缩效率惊人!!

    1)针对Apache2.0之前的版本,它原本是不支持的,不过可以通过添加第三方的module_gzip模块来启用2)针对Apache2.0及之后的版本,Apache 提供支持, 不过不叫gzip,而叫mod_deflate下面就对Apache2.0及之后的版本作一个说明。

    1.开启 gzip模块   LoadModule deflate_module modules/mod_deflate.so2. 在httpd.conf中增加下面的内容:<Location />    # Insert filter    SetOutputFilter DEFLATE    # 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 \bMSIE !no-gzip !gzip-only-text/html      # Don't compress images    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary    # Make sure proxies don't deliver the wrong content    # Header append Vary User-Agent env=!dont-vary</Location>

    3. 重启Apache进程即可。

     

    转载请注明原文地址: https://ju.6miu.com/read-679106.html

    最新回复(0)