Home > all about web > Compression File in Apache Tomcat (GZIP)

Compression File in Apache Tomcat (GZIP)

What is GZIP?

It is a compression format created by Jean-Loup Gailly and Mark Adler. Version 0.1 was first publicly released on October 31, 1992.

GZIP is based on the DEFLATE algorithm, which is a combination of LZ77 and Huffman coding. DEFLATE was intended as a replacement for LZW and other patent-encumbered data compression algorithms which, at the time, limited the usability of compress and other popular archivers.

How does it helps in improving performance of my web page?

Modern browser like Internet Explorer, Firefox, Opera etc supports gzip compressed content. These browsers are capable of uncompressing gzip data into plain text. Servers like Apache, Tomcat, JBoss etc supports gzip compression too. Hence if gzip is enabled in such servers, the response if first compressed and then send to client. Hence this increase performance by many folds.

How to enable GZIP in my tomcat server?

Here is how to enable GZIP compression on Tomcat: edit file /conf/server.xml and add to the HTTP Connector configuration something like this:

compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"

An example of a HTTP Connector configuration with compression enabled could be:

<Connector port="8080" maxHttpHeaderSize="8192"
        maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
        enableLookups="false" redirectPort="8443" acceptCount="100"
        connectionTimeout="20000" disableUploadTimeout="true"
        compression="on"
  compressionMinSize="2048"
  noCompressionUserAgents="gozilla, traviata"
  compressableMimeType="text/html,text/xml"/>

Check out following header information before enabling GZIP.And after enabling GZIP look at the size of the webpage and the time taken for loading with firebug.  
Just Share .. try it :D 

Advertisement
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.