Skip to content

compress: add Vary to cached client responses - #13580

Open
traeak wants to merge 1 commit into
apache:masterfrom
traeak:compress_vary
Open

compress: add Vary to cached client responses#13580
traeak wants to merge 1 commit 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compress compress plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants