3

I have enabled compression on Tomcat running on my machine. The https response header is showing compression is enabled, but the same amount of data is being transferred with and without compression turned on.

Without compression:

Status OK
Code    200
Encoded 218.89 KB
Decoded 218.89 KB
Transfered  219.22 KB
Compressed  No

With compression:

Status  OK
Code    200
Encoded 218.89 KB
Decoded 218.89 KB
Transfered  219.26 KB
Compressed  Yes
Compression 1.00×

I can see Content-Encoding as gzip in response header.

My connector definition in server.xml follows:

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS"
           keystoreFile="xxxxx" keystorePass="xxxx"
           useSendfile="false" compression="force" />

I am using Tomcat 8.0.12. Browsers are latest versions of Safari running on MAC OS X Yosemite.

Detailed info with compression ON

Detailed info with compression OFF

Edit: As per Tim's answer, I was misled by the Safari reporting numbers. See stackoverflow.com/a/21943693/3944823.

Clayton
  • 133
  • 4
  • 1
    what is your compressionMinSize ? also, compression + https = danger – Neil McGuigan Feb 25 '16 at 21:30
  • It is the default "2048" bytes. I tried explicitly setting it to "2048" and also a very low value "3" with no changes in results. Thanks for the heads up on the vulnerability this opens, but I am willing to explore the benefits of compression. – Clayton Feb 26 '16 at 11:39
  • Are you sure that it's Tomcat that's not working? It could be that the web browser is incorrectly reporting content size rather than transfer size. Check it with another web browser, or check the web server access logs. – Tim Mar 02 '16 at 20:23
  • @Tim: You're right! Checking in Chrome clearly shows the content is being compressed (Network->Size column). For each applicable file, it shows the "size" (what's transferred on the wire) is much smaller than the "content". – Clayton Mar 03 '16 at 13:46
  • Knowing now it is a Safari thing, I see this is probably a duplicate of http://stackoverflow.com/a/21943693/3944823. The second answer nails the reason why I was on a wrong path. – Clayton Mar 03 '16 at 13:48
  • I'll write it up as an answer so you can accept it, so others don't have to spend time on it. – Tim Mar 03 '16 at 18:10

1 Answers1

1

Are you sure that it's Tomcat that's not working? It could be that the web browser is incorrectly reporting content size rather than transfer size. Check it with another web browser, or check the web server access logs.

Note - confirmed as per comments above.

Tim
  • 30,383
  • 6
  • 47
  • 77