compressor: add weaken_etag_on_compress to weaken strong ETags when compressing#43755
compressor: add weaken_etag_on_compress to weaken strong ETags when compressing#43755rafaelgaspar wants to merge 3 commits intoenvoyproxy:mainfrom
Conversation
|
Hi @rafaelgaspar, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
ba6a487 to
3bcab8f
Compare
|
cc @adisuissa Gentle ping for the review. |
|
@rafaelgaspar It also needs a main merge. /wait |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks! left a couple of high-level API comments.
| // response body was modified by compression. When ``false`` (default), strong ETags are | ||
| // removed when compression is applied. This option has no effect when ``disable_on_etag_header`` | ||
| // is ``true`` (compression is skipped for responses with ETag). | ||
| bool weaken_etag_on_compress = 6; |
There was a problem hiding this comment.
Please move next to the disable_on_etag_header field.
| // removed when compression is applied. This option has no effect when ``disable_on_etag_header`` | ||
| // is ``true`` (compression is skipped for responses with ETag). |
There was a problem hiding this comment.
If the fields weaken_etag_on_compress and disable_on_etag_header are conflicting (cannot set both to true), then the suggested API flow will be prioritizing the new field over the old one in the case both are set.
The reason is to support gradual rollout of the feature support to clients and servers.
Introduces a new configuration option, `weaken_etag_on_compress`, to the compressor filter's response direction configuration. When enabled, strong ETag headers are modified to include a "W/" prefix instead of being removed during compression, allowing for better cache and conditional request handling. Updates to documentation and tests have been made to reflect this new behavior. Signed-off-by: Rafael Antunes <rafael.gaspar@me.com>
3bcab8f to
974d00d
Compare
Updated the compressor filter to clarify the precedence of the `weaken_etag_on_compress` option when both it and `disable_on_etag_header` are enabled. Compression will now be applied, and the ETag will be weakened, allowing for better cache management. Documentation and tests have been updated to reflect this behavior. Signed-off-by: Rafael Antunes <rafael.gaspar@me.com>
Signed-off-by: Rafael Antunes <rafael.gaspar@me.com>
|
@adisuissa both suggestions have been incorporated into the code, let me know if there is anything else. |
|
@adisuissa re-ping for "stalled" bit. |
Generative AI Disclaimer: This PR was prepared with assistance from generative AI (Cursor). The implementation, tests, and documentation have been fully reviewed by me as the PR author, and I take responsibility for the changes.
Commit Message:
compressor: add weaken_etag_on_compress to weaken strong ETags when compressing
Additional Description:
Adds a new option
weaken_etag_on_compressto the compressor filter'sresponse_direction_config. When enabled, strongETagresponse headersare weakened by prepending
W/to the value (e.g."abc123"becomesW/"abc123") instead of being removed when compression is applied. WeakETags (already starting with
W/) are left unchanged.This allows caches and conditional requests to keep working while indicating
that the representation was modified by compression, matching behavior used in
other proxies (e.g. Varnish). The default remains
false, preservingexisting behavior (strong ETags are removed when compressing).
Fixes #35152
Risk Level: Low
Testing:
New unit tests in
compressor_filter_test.cc:WeakenEtagOnCompressStrongEtag– strong ETag is weakened when compressingWeakenEtagOnCompressStrongEtagWithQuotes– strong ETag with quotes is weakenedWeakenEtagOnCompressWeakEtagUnchanged– weak ETag is preservedWeakenEtagOnCompressWithStatusHeaderEnabled– weaken behavior with status header enabledDocs Changes: Yes
docs/root/configuration/http/http_filters/compressor_filter.rstwith an "ETag handling" section describingdisable_on_etag_headerandweaken_etag_on_compress, and added a YAML example forweaken_etag_on_compress.EtagNotAllowedstatus andnot_compressed_etagstat descriptions.Release Notes: Yes
new_featuresinchangelogs/current.yamlfor the compressor filter'sweaken_etag_on_compressoption.Platform Specific Features: N/A