I have added the following lines in tomcat's conf/server.xml file to enable gzip compression but its not working. Pages are still uncompressesd.
<Connector port="8080" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/plain,text/css, text/javascript,text/json,application/x-javascript, application/javascript,application/json"/>
Any idea?
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" Code language: HTML, XML (xml)
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.
Gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix. Want to master Tomcat Server ? Subscribe to our newsletter and download the Apache Tomcat Cookbook right now!
this could certainly be useful if you are running Tomcat standalone, and using apache compression is simply unavailable. anyways gud job. Thanks Aditiya for the comment… Definitely Apache server can be used that can do this..
If Tomcat is fronted by Apache on port 80, you will need to enable compression in Apache itself. The compression in Tomcat will only work if you access it directly on port 8080.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With