I have a default property server.compression.enabled=true in application.properties using Spring Boot 2.3.7.RELEASE.

when spring-boot-starter-tomcat is on classpath, and response header has a strong ETag,compression doesn't take effect and Content-Encoding is disappeared,

HTTP/1.1 200
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
ETag: "3343:Tue Dec 29 13:59:45 CST 2020"
Cache-Control: no-cache, must-revalidate, public
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Length: 911883
Date: Wed, 30 Dec 2020 14:50:02 GMT
Keep-Alive: timeout=60
Connection: keep-alive

but, when I switch to spring-boot-starter-undertow, compression take effect

HTTP/1.1 200 OK
Content-Encoding: gzip
Cache-Control: no-cache, must-revalidate, public
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Date: Wed, 30 Dec 2020 14:44:49 GMT
Connection: keep-alive
ETag: "3343:Tue Dec 29 13:59:45 CST 2020"
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
Transfer-Encoding: chunked
Content-Type: application/json

Comment From: jnizet

I think that's already fixed. See https://github.com/spring-projects/spring-boot/issues/23464 and https://github.com/spring-projects/spring-framework/issues/24898

Comment From: philwebb

@lmtoo Can you please check if upgrading to the latest Spring Framework 5.3 version (perhaps via Spring Boot 2.4) fixes your issue?

Comment From: lmtoo

It's no different, still don't have Content-Encoding header, org.springframework.boot.web.embedded.tomcat.CompressionConnectorCustomizer#customize didn't call org.apache.coyote.http2.Http2Protocol#setNoCompressionStrongETag

Comment From: philwebb

@lmtoo Did you mean to close the issue?

Comment From: mdmm13

Was this ever resolved for Tomcat? (Update: we're on the latest Spring Boot 3.2.2)

We just added the ShallowEtagHeaderFilter and responses are no longer enjoying gzip compression. Would anyone be able to point me in the direction of where this combination is documented?

==> Update for anyone trying to get this working, you have to set the setWriteWeakETag of the ShallowEtagHeaderFilter for it to work with Tomcat (see here).

==> Update 2: note that you will lose the content-length header if you do this per this spring-projects/spring-framework#32279