Apache+负载均衡+gzip(自带的)

流水帐:

    <IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    SetInputFilter DEFLATE

    #the two above compress everything unless excluded below
    SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary             
    SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary            
    SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary    
    SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary     
    SetEnvIfNoCase Request_URI \.plist$ no-gzip dont-vary  

    # Below is an example where you get rid of what's above and you explicity compress
    AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp application/x-javascript application/x-httpd-eruby text/js text/html image/jpg image/jpeg image/gif image/png text/css
    DeflateFilterNote ratio
    DeflateCompressionLevel 9
    LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
    CustomLog logs/deflate_log deflate
    </IfModule>


    <Directory "XXX">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    </Directory>

    <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName localhost
    ServerAlias clm
    ProxyPass /images/ !
    ProxyPass /stylesheets/ !
    ProxyPass /javascripts/ !
    Alias /stylesheets/ "XXX/stylesheets/"
    Alias /images/ "XXX/images/"
    Alias /javascripts/ "XXX/javascripts/"
    ProxyPass / balancer://clm_balancer/
    ProxyPassReverse / balancer://XXX_balancer/
    ErrorLog logs/clm-error.log
    CustomLog logs/clm-access.log common
    </VirtualHost>

    <Proxy balancer://XXX_balancer>
    BalancerMember http://localhost:3000
    BalancerMember http://localhost:3001
    BalancerMember http://localhost:3002
    BalancerMember http://localhost:3003
    BalancerMember http://localhost:3004
    BalancerMember http://localhost:3005
    </Proxy>



对于js,css文本文件压缩还可以,image压缩没有我想象的那么惊讶,效果不是很好。

参考:
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#recommended
http://schroepl.net/projekte/mod_gzip/config.htm
【原生gzip,但好像apache2.x支持不好,遂选择apache自带的mod_deflate】

补充,在做apache要所之前,已经用jsbuilder压缩过js,效果不错,以前就用过,随手拈来,效率还可以,只是在折腾gzip的时候耗费些时间。

你可能感兴趣的:(JavaScript,apache,PHP,css,Gmail)