An example of a HTTP Connector configuration with compression enabled could be:Code language: HTML, XML (xml)compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml"
<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"/>
Code language: HTML, XML (xml)
Check out following header information before enabling GZIP. Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
He dude, why do you wanna do compression on tomcat/coyote..
most of the people ,when they go production, put the tomcat behind an apache or lighttpd or nginix , as a cluster
why not the actual webserver do the compression..tomcat compresses in java....while these web servers do it natively..thus much faster and production suitable.
from somewhere on internet:
this could certainly be useful if you are running Tomcat standalone, and using apache compression is simply unavailable.
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=56&t=003260
anyways gud job.
cheers
Aditya
Thanks Aditiya for the comment...
Definitely Apache server can be used that can do this.. But sometime back, I wanted to use only Tomcat and hence this code.
anyways. thanks for the info :)
Cheers,
Viral
Can anyone help me?????
I have modified the server.xml conf file to set the \"compression\" properties as specified above in the connector tag.
I have tested this in FireFox in which I am able to notice the difference in the size. But When tested in the IE7 there is no difference in the size of the page. Can anyone explain me how to figure out the issue with IE7.
Hi Sateesh,
Use some plugins for IE to check HTTP Header and see if the CONTENT-ENCODING is GZIP. You can use http://www.debugbar.com/download.php to check this.
Thanks Viral for your help.
I had installed the debugger and checked for the output and not found the Content-Encoding, but seen Transfer-Encoding for which the value is \"chunked\". In IE I noticed the size is 6030 bytes but in FF it is 1519 bytes.
I turned off the Compression and verified the output. The size is same in IE and FF (6030 bytes). Now the Transfer-Encoding header was vanished. Can you kindly let me know why the gzip is not working in IE and how to initialize the compression in IE.
Thanks in advance.
I turned on tomcat compression, but I require a java client to get the result that is returned and decompress the data in the client. I have tried to use GZipInputStream, but I get IOException: GZip trailer. Can any one help? Ignoring this block is not an option.
Hi Dear,
I have enabled this option but after that web page is opening without compress mode, please help...?
@Lovelesh - Make sure you also add the mime types for javascript and css. My tomcat wasn't compressing those until I added these mimetypes:
text/html,text/xml,text/plain,text/css,text/javascript
Hi Ashish, thanks for reply.
I have added as given your reply but it is still working with unzip mode: I am adding here code please review:
""
..please help
Hi all,
Now i would like to compress the javascript and css files in tomcat 6.0.20 (windows vista),
1. Moidified server.xml like this:
2. then test it in firefox 3.5, but i seem doesn't work, why?
Can you help me?
Thanks in advance!