Sunday, June 21, 2015

How to enable compression on Tomcat?

Problem Statement: My web page is loading very slow.
Solution: Check out the reason for the same on Pagespeed insights tool from google here

The most probable solution which is offered today for Mobile and Desktop is to enable compression.
And if you are using Tomcat then this is a cake wake.

Here is how to enable compression on Tomcat:
1. Go to the path where you have installed Tomcat i.e cd tomcat/conf
2. Open server.xml and search for the pattern :
<Connector URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />


3. Change this to :
<Connector URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1"
                connectionTimeout="20000"
                compression="on"
                compressionMinSize="512"
                compressableMimeType="application/json,application/xml,image/gif,image/png,text/css,text/html,text/javascript,text/plain,text/xml"
               redirectPort="8443" />

4. That's it. Now restart tomcat and check out the page speed again using google tool to analyse it.

I am working on Pentaho systems which uses tomcat server and got the solution from http://jira.pentaho.com/browse/BISERVER-10222


No comments:

Post a Comment