Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my Tomcat v6.0 localhost Server Enable compression "gzip"?

I have finished development of a Java EE web application
Under Eclipse IDE and Tomcat v6.0 as a localhost Server
Now I need to make my localhost Server (Tomcat v6.0) Enable compression "gzip"
For static resources as (JavaScript files, CSS files , Images , ...)

like image 352
ahmednabil88 Avatar asked Dec 06 '22 09:12

ahmednabil88


2 Answers

Open /conf/server.xml, add this configuration in your HTTP connector:

compression="on"
compressionMinSize="2048"
compressableMimeType="application/javascript, text/css"

For example:

 <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443"
               compression="on"
               compressionMinSize="2048"
               compressableMimeType="application/javascript, text/css"/>

More Apache Tomcat HTTP

like image 164
Iswanto San Avatar answered Dec 22 '22 01:12

Iswanto San


If you want to gzip js and css files than Iswanto San's answer is correct.

If you want to gzip html pages then the following configuration should help.

compression="on" 
compressionMinSize="2048" 
compressableMimeType="text/html,text/xml"

If you want to gzip all response

compressableMimeType="text/html, text/xml,text/plain,text/javascript,text/css"
like image 29
Serkan Arıkuşu Avatar answered Dec 22 '22 01:12

Serkan Arıkuşu