大网数据广告活动
服务器运维问答

Tomcat/https: I can see compression is enabled, but file sizes are the same as without compression

· 52CE 我爱测

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…

问题原文

原帖链接 · Clayton Lovatto · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · Tim · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。