You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: compress() doesn't set Vary: Accept-Encoding #5886
Responses that go through the compress() middleware include Vary: Accept-Encoding, added to any Vary value that's already set, so shared caches like CloudFront keep the gzip and plain versions apart.
Current Behavior
compress() sets Content-Encoding: gzip but never sets Vary. When cors() is used too, the response only has Vary: Origin. A shared cache can then send a gzip body to a client that didn't ask for one. The sample response in the docs (advanced_compress_res.json) shows the same thing: Content-Encoding: gzip and no Vary.
Call the handler with an API Gateway REST event for GET /data with Accept-Encoding: gzip.
The response has Content-Encoding: gzip and no Vary header.
Possible Solution
Add Accept-Encoding to Vary on responses that go through compress(), keeping any existing value (like Origin from cors()) and leaving Vary: * alone. The Python version is making the same change in aws-powertools/powertools-lambda-python#8711. I'm happy to send a PR for this.
Thank you for reporting the issue, I was able to confirm the bug and will be opening a PR to fix it shortly.
Thanks for offering to fix it, in this instance I found it faster to open the PR since there were a few decision points that would have caused back & forth if discussed here, specifically around how to handle the consistency with CORS.
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
dreamorosi commentedon Nov 2, 2026
Thank you for reporting the issue, I was able to confirm the bug and will be opening a PR to fix it shortly.
Thanks for offering to fix it, in this instance I found it faster to open the PR since there were a few decision points that would have caused back & forth if discussed here, specifically around how to handle the consistency with CORS.
powertools-for-aws-oss-automation commentedon Nov 2, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.