• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nagendra Suresh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you receiving content-type headers that correspond to the list of compressable MIME types?
 
Nagendra Suresh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic