Skip to content

compress: add Vary to cached client responses - #13580

Merged
traeak merged 2 commits into
apache:masterfrom
traeak:compress_vary
Aug 25, 2026
Merged

compress: add Vary to cached client responses#13580
traeak merged 2 commits into
apache:masterfrom
traeak:compress_vary

Conversation

@traeak

@traeak traeak commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Related to Vary header for compressible content (#12741).
If a compressible cached object did not have the vary header (like after an ATS upgrade from 10.0.x to 10.1.x), the plugin gets read only access to the cached header and tries to add the Vary header. This triggers errors in the logs for every matching request and doesn't add the Vary header to a client response.

[Aug 20 15:54:54.873] [ET_NET 25] ERROR: <InkAPI.cc:252 (TSError)> [/rpmbuilddir/BUILD/trafficserver-10.1.4/plugins/compress/compress.cc:297] [vary_header] ERROR: cannot add/update the Vary header
[Aug 20 15:54:54.873] [ET_NET 25] ERROR: <InkAPI.cc:252 (TSError)> [/rpmbuilddir/BUILD/trafficserver-10.1.4/plugins/compress/compress.cc:939] [add_vary_header_for_compressible_content] ERROR: failed to add Vary header for compressible content

With this fix the Vary header is added at the client response header hook if it does not already exist in the client response.

@traeak traeak self-assigned this Aug 21, 2026
Copilot AI lite review requested due to automatic review settings August 21, 2026 13:04
@traeak traeak added the compress compress plugin label Aug 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the compress plugin to avoid attempting to mutate cached response headers (which can be read-only in some upgrade/cached-object scenarios) and instead ensures Vary: Accept-Encoding is present on the client response when serving a cached, compressible object. It also adds a gold test to exercise the cached-object path and assert the plugin no longer logs errors while producing the expected headers/body.

Changes:

  • Adjust compress plugin flow so Vary: Accept-Encoding is added to origin responses before caching, and (for cached hits) added at TS_HTTP_SEND_RESPONSE_HDR_HOOK to the client response.
  • Add a new gold test that seeds cache without the plugin, then verifies cached delivery through the plugin adds Vary: Accept-Encoding without Content-Encoding when the client omits Accept-Encoding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
plugins/compress/compress.cc Adds a client-response Vary update path for cached hits via TS_HTTP_SEND_RESPONSE_HDR_HOOK, while keeping origin-response Vary insertion for cacheable origin responses.
tests/gold_tests/pluginTest/compress/compress-vary-cached-response.test.py New regression test covering cached-hit behavior and verifying both headers and body while asserting no mutation-error logs occur.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bryancall
bryancall requested a review from serrislew August 24, 2026 22:09
@bryancall bryancall added this to the 11.0.0 milestone Aug 24, 2026
@bryancall bryancall added the Bug label Aug 24, 2026
Comment thread plugins/compress/compress.cc Outdated
serrislew
serrislew previously approved these changes Aug 25, 2026
Copilot AI review requested due to automatic review settings August 25, 2026 12:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@traeak
traeak merged commit 4676308 into apache:master Aug 25, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Aug 25, 2026
cmcfarlen pushed a commit that referenced this pull request Aug 25, 2026
* compress: add Vary to cached client responses

* rename function to add_vary_header_to_server_response

(cherry picked from commit 4676308)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug compress compress plugin

Projects

Status: For v10.2.1

Development

Successfully merging this pull request may close these issues.

4 participants