Compressing HTML Content in Tomcat 6
One of the nice things about tomcat 5.5 and tomcat 6.0 is the built-in support for http 1.1 gzip-based compression. If you want to enable compression for bandwidth savings or you are looking for the performance benefits (or both), enabling compression in tomcat is relatively simple. In all actuality though, enabling compression is quickly becoming a requirement for any site utilizing AJAX. On the one main site I manage, it is not unusual to see 750K, 1MB, and higher page weights. Compression can reduce these by up to 80% or more, which provides faster downloads to your customers and lower bandwidth costs.
Edit your server.xml file and look for your http connector. You will add a new value: compression="on". Save the file and restart tomcat. Please note that compression is only valid for the HTTP connector and not the AJP connector. If you front-end your tomcat server with apache or IIS and the mod_jk connector, you will not really be able to take advantage of HTTP Compression easily.
Before Enabling Compression
For people who do not use Safari, the exclamation point in front of the entry for changelog.html is a message that indicates that turning compression on will result in bandwidth savings, faster download times, etc.
After Enabling Compression
As you can see from this basic example, the Web Inspector built into Safari reports that the transfer time has been cut by approximately 40ms and this is just for the one html file. As page weights get heavier with the addition of stylesheets and scripts, you will start to see an even more dramatic difference.
Edit your server.xml file and look for your http connector. You will add a new value: compression="on". Save the file and restart tomcat. Please note that compression is only valid for the HTTP connector and not the AJP connector. If you front-end your tomcat server with apache or IIS and the mod_jk connector, you will not really be able to take advantage of HTTP Compression easily.
Before Enabling Compression
For people who do not use Safari, the exclamation point in front of the entry for changelog.html is a message that indicates that turning compression on will result in bandwidth savings, faster download times, etc.
After Enabling Compression
As you can see from this basic example, the Web Inspector built into Safari reports that the transfer time has been cut by approximately 40ms and this is just for the one html file. As page weights get heavier with the addition of stylesheets and scripts, you will start to see an even more dramatic difference.



















