File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes No Content-Encoding in Response headers, how to make tomcat perform gzip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "No Content-Encoding in Response headers, how to make tomcat perform gzip" Watch "No Content-Encoding in Response headers, how to make tomcat perform gzip" New topic
Author

No Content-Encoding in Response headers, how to make tomcat perform gzip

Nagendra Suresh
Greenhorn

Joined: Dec 29, 2012
Posts: 6
Hi Experts ,

I have deployed a web application on Tomcat . Now I am trying to optimize the performance . I have added the followin lines in the conf/server.xml of the tomcat container.

compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/css,text/javascript,text/json,text/jsp,
application/x-javascript,
application/javascript,application/json"

I am using the mozilla firebug extension to see the request and response headers . The request headers has a field accept encoding which has gzip in it . However in the respone headers I have no Content-encoding field present . I have cleared the cache completely .

Can anyone help me on how I can make Tomcat to gzip the content before sending the content to the browser?

I have used Page insight as well and it asks me to compress the content .


Appreciate the help experts.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Are you receiving content-type headers that correspond to the list of compressable MIME types?


Customer surveys are for companies who didn't pay proper attention to begin with.
Nagendra Suresh
Greenhorn

Joined: Dec 29, 2012
Posts: 6
Hi ,

I do not see any content encoding fields in the headers at all . I have also tried to clear the cache , no luck yet . Any idea where I might be going wrong?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

You have to set the content-type headers yourself. Tomcat cannot deduce what they should be, not least because not only do so many content types look alike, but because in some cases, such as Microsoft Excel spreadsheets, there's more than one "standard" content-type defined.

Tomcat will read the content-type header as the response as sent and use that to determine whether to compress the datastream or not. Or, if you want to be more accurate, the Valve that you configured will.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: No Content-Encoding in Response headers, how to make tomcat perform gzip