#AskMe

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

<Connector port="8080" protocol="HTTP/1.1" 
       connectionTimeout="20000" 
       redirectPort="8443"/>
<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.