• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Tomcat 8 GZIP compression not working

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I configed Tomcat 8 (server.xml) as follows:


<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml" />


However I do not see the response (about 8k in size) is compressed. In Chrome I can use F12 to view the content/size is still 8k/8k as opposed to something like 2k/8k.


Any ideas?
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can only make a few wild guesses.

First, your connector is set to listen on port 80. Make sure that your test URL is addressing port 80, and not the usual Tomcat port 8080. If you don't include an explicit port ID in the URL (ex: "http://xxx.com:8080"), of course, the http: protocol will be using port 80, but it's worthwhile to make sure. If you're talking to a port and it's not a port configured for compression, then you'd certainly have a problem.

Secondly, the compression (and encryption), if any between client and server are negotiated based on what the server can offer and what the client can accept and will be the lowest-common-denominator of the two. Verify that your client can handle compression.

One thing: For Tomcat to listen on port 80 (or any port less than 4096), it either has to be running as a privileged user or using the "port 80 wrapper". Running as a privileged user is a security risk and is not recommended. Commonly, Tomcat will be fronted with a reverse-proxy server such as Apache httpd or nginx, which gives the dual advantage of being able to handle port 80 without running privileged (using resources that Java apps can't) and of being able to handle a mix of J2EE and non-J2EE apps (such as python and php).
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic