Thursday, June 30, 2011

Gzip in Apache Tomcat - Faster Responses with Compression

Today's Browser have capability to support gzip content and uncompressed the content to plain text. The data comes from server to client in a compressed form with increases the performance many times as less data get transfered on network.

Just go to Tomcat/conf/Server.xml file and replace the default node

<Connector port="8080" protocol="HTTP/1.1"
redirectPort="8443" >

with follwing

<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
noCompressionUserAgents="gozilla, traviata"

Make sure you add the MIME Type which you want to add compression as follows

# Tomcat handles the compression for the supporting brorwers and do not compress response in case the browser is from monolithic age :)

- Varun Rathore

1 comment:

Pranav said...


I am using spring along-with tomcat7. I am sending big json (aprrox 1 MB) in http response call.
But even after making those changes I am still not able to compress my JSON data.
All view pages although are getting compressed.

I have added application/json mime type as well.

Can you suggest further steps to debug this?

About Me