« Tomcat 6 Access Logging | Main | Camino 1.6.3 Released »

08/14/2008

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.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a01156fbc6fe6970c011572288131970b

Listed below are links to weblogs that reference Compressing HTML Content in Tomcat 6:

Comments

Alibris connects people who love books, music, and movies to thousands of independent sellers around the world. Search over 60 million used & new books, music, & movies to find great deals!



Click here to get Comodo Internet Security Pro at 50% Off

30% off select Xbox games from the Microsoft Store with promo code: CLR-MSFT-Games-30%. Offer valid through March 31st.

Webroot Software Inc.


Follow techstacks on Twitter


Add to favourite links

Add to Google Reader or Homepage

Subscribe in NewsGator Online

Add to netvibes

Subscribe in Bloglines

Subscribe to Blogging Techstacks in Rojo

Add Blogging Techstacks to Pageflakes

Add Blogging Techstacks to fwicki

Tip Jar

For Donations

Tip Jar
Creative Commons Attribution-ShareAlike 3.0 Unported
Powered by WebRing.