Enable GZIP Compression In Tomcat

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:



출처 - http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/




'Web > Common' 카테고리의 다른 글

web - woff, eot  (0) 2014.04.21
웹 페이지 속도 개선  (0) 2014.03.18
web - HATEOAS  (0) 2014.01.12
web - SPDY  (0) 2014.01.09
해상도  (0) 2013.11.19
Posted by linuxism
,