While not being expert in web server maintenance it came as surprise to me that seemingly still in year 2011 default configuration of apache2 (nor tomcat6) isn’t enabling compression by default. Instead some manual tweaking is required.
So steps are:
Step 1:
[code]
vim /etc/sysconfig/apache2
[/code]
Append following into file
[code]
APACHE_MODULES=”… jk deflate”
vim /etc/apache2/vhosts.d/your-vhost.conf
[/code]
Step 2:
We are not yet done
[code]
vim /etc/apache2/vhosts.d/your-vhost.conf
[/code]
And add following block into file
[code]
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
[/code]
Repeat that for all vhosts.
Step 3:
And finally restart apache
[code]
/etc/init.d/apache2 restart
[/code]
Step 4:
And test if compression is now working
Done,,, for Apache2 part
Then lets attack tomcat6
…
Step 1:
Enable compression in config file
[code]
vim /opt/tomcat6/conf/server.xml
[/code]
This should to the trick
[code]
….
[/code]
Step 2:
Restart server
[code]
/opt/tomcat6/bin/catalina.sh stop
/opt/tomcat6/bin/catalina.sh start
[/code]
References:
Apache2 gzip compression: How do I speed up my website download time?
Enable GZIP compression in tomcat
GZip compression test