Categories
Apache Tomcat

GZip Compression on Web App Deployed with Tomcat

Performance is very important to save resource for visitors using our website.

If you deploy your Java Web Application on Apache Tomcat and you feel it’s a bit slow, please check it out my experience on solving issue of gzip compression by changing configuration of Apache Tomcat.

Result: Before/After Correction

Solutions

  • Edit file: apache-tomcat-xx\conf\server.xml change setting connection from:
<Connector port="8080" protocol="HTTP/1.1" 
       connectionTimeout="20000" 
       redirectPort="8443"/>
  • To add some lines as following:
<Connector port="8080" protocol="HTTP/1.1" 
       connectionTimeout="20000" 
       redirectPort="8443" 
       compression="on" 
       compressionMinSize="10" 
       noCompressionUserAgents="gozilla, traviata" 
	   compressableMimeType="text/html,text/xml,text/javascript,text/css"/>

Tips & Warning

You need to restart your tomcat server for any change of configuration file such as server.xml file.

One reply on “GZip Compression on Web App Deployed with Tomcat”

My own solution shared in the post above, hope it helps others.

Please help to vote if it is helpful for you in this comment as answer.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.