Skip to content

Compress plugin can double compress on 304s without content-encoding #6852

@ezelkow1

Description

@ezelkow1

curl http://localhost:8080/test.txt -Lvsk -H "Accept-Encoding: br,deflate,gzip" -o /dev/null

Trying ::1:8080...
Connected to localhost (::1) port 8080 (#0)
 GET /test.txt HTTP/1.1
 Host: localhost:8080
 User-Agent: curl/7.69.1
 Accept: */*
 Accept-Encoding: br,deflate,gzip

 Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
< Content-Type: text/plain
< Accept-Ranges: bytes
< Date: Thu, 04 Jun 2020 17:39:40 GMT
< Server: ATS/10.0.0
< Etag: "1311141015-df"
< Cache-Control: public
< Content-Encoding: br
< Content-Length: 1048929
< Age: 0
< Connection: keep-alive
<
{ [43434 bytes data]

This was using lighttpd as a test origin. I had already requested this content previously
This is the cached alternate that ATS found:

GET http://localhost:80/test.txt HTTP/1.1
Host: localhost:80
User-Agent: curl/7.69.1
Accept: */*
Accept-Encoding: br, gzip
Client-ip: ::1
X-Forwarded-For: ::1

HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Encoding: gzip
Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
ETag: "1311141015"
Content-Type: text/plain
Accept-Ranges: bytes
Expires: Thu, 04 Jun 2020 17:39:01 GMT
Cache-Control: max-age=60
Cache-Control: public
Content-Length: 1048900
Date: Thu, 04 Jun 2020 17:38:01 GMT
Server: lighttpd/1.4.54

Then determined it needed to reval due to age:
[Jun 4 17:39:40.499] [ET_NET 15] DEBUG: <HttpTransact.cc:2810 (HandleCacheOpenReadHit)> (http_trans) [2] CacheOpenRead --- send_revalidate = 1
[Jun 4 17:39:40.499] [ET_NET 15] DEBUG: <HttpTransact.cc:2813 (HandleCacheOpenReadHit)> (http_trans) [2] CacheOpenRead --- HIT-STALE

and created this request for reval

+++++++++ Proxy's Request after hooks +++++++++
-- State Machine Id: 2
GET /test.txt HTTP/1.1
Host: localhost:80
User-Agent: curl/7.69.1
Accept: */*
Accept-Encoding: br, gzip
Client-ip: ::1
X-Forwarded-For: ::1
Via: http/1.1 traffic_server[0db34ec6-fedc-4d40-8aec-b82cdaf0c879] (ApacheTrafficServer/10.0.0)
If-Modified-Since: Thu, 04 Jun 2020 17:36:45 GMT
If-None-Match: "1311141015"

Apparently lighttpd does not return an encoding for 304 requests, or at least it doesnt the way I have it configured, so compress just saw the responses content-type:
[Jun 4 17:39:40.500] [ET_NET 15] DIAG: (compress) INFO: reading response headers
[Jun 4 17:39:40.500] [ET_NET 15] DIAG: (compress) INFO: compressible content type [text/plain], matched on pattern [text/*]
[Jun 4 17:39:40.500] [ET_NET 15] DIAG: (compress) DEBUG: [compress/compress.cc:774] [compress_transform_add] TransformedRespCache not enabled
[Jun 4 17:39:40.500] [ET_NET 15] DIAG: (compress) DEBUG: [compress/compress.cc:116] [data_alloc] brotli compression. Create Brotli Encoder Instance.

-- State Machine Id: 2
HTTP/1.1 304 Not Modified
Vary: Accept-Encoding
Content-Type: text/plain
Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
ETag: "1311141015"
Cache-Control: public
Date: Thu, 04 Jun 2020 17:39:40 GMT
Server: lighttpd/1.4.54

However ATS still had the origin unmodified header:

+++++++++ Header To Transform +++++++++
-- State Machine Id: 2
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Encoding: gzip
Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
Content-Type: text/plain
Accept-Ranges: bytes
Date: Thu, 04 Jun 2020 17:39:40 GMT
Server: lighttpd/1.4.54
Etag: "1311141015"
Cache-Control: public

and then proceeded to do a brotli compress anyway:
[Jun 4 17:39:40.508] [ET_NET 15] DIAG: (compress) DEBUG: [compress/compress.cc:502] [brotli_transform_finish] brotli-transform: Finished brotli
[Jun 4 17:39:40.508] [ET_NET 15] DIAG: (compress) INFO: Compressed size 1048929 (bytes), Original size 1048900, ratio: -0.000028
[Jun 4 17:39:40.508] [ET_NET 15] DIAG: (compress) DEBUG: [compress/compress.cc:513] [compress_transform_finish] compress_transform_finish: brotli compression finish

at which point it then tacked on another Content-Encoding field:

+++++++++ Header From Transform +++++++++
-- State Machine Id: 2
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Encoding: gzip
Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
Content-Type: text/plain
Accept-Ranges: bytes
Date: Thu, 04 Jun 2020 17:39:40 GMT
Server: lighttpd/1.4.54
Etag: "1311141015-df"
Cache-Control: public
Content-Encoding: br
Content-Length: 1048929

and sent that to the client:

+++++++++ Proxy's Response 2 +++++++++
-- State Machine Id: 2
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Encoding: gzip
Last-Modified: Thu, 04 Jun 2020 17:36:45 GMT
Content-Type: text/plain
Accept-Ranges: bytes
Date: Thu, 04 Jun 2020 17:39:40 GMT
Server: ATS/10.0.0
Etag: "1311141015-df"
Cache-Control: public
Content-Encoding: br
Content-Length: 1048929
Age: 0
Connection: keep-alive

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions