compress: add Vary to cached client responses - #13580
Open
traeak wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
compressplugin flow soVary: Accept-Encodingis added to origin responses before caching, and (for cached hits) added atTS_HTTP_SEND_RESPONSE_HDR_HOOKto the client response. - Add a new gold test that seeds cache without the plugin, then verifies cached delivery through the plugin adds
Vary: Accept-EncodingwithoutContent-Encodingwhen the client omitsAccept-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
With this fix the Vary header is added at the client response header hook if it does not already exist in the client response.