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: compressed routes do not send Vary: Accept-Encoding #8710
When compression is enabled for a route (@app.get(..., compress=True) or Response(compress=True)), the response body depends on the request's Accept-Encoding, so the response should carry Vary: Accept-Encoding. That tells API Gateway caching, CloudFront and other shared caches to keep gzipped and plain responses apart. This is the same reasoning as the Vary: Origin that CORS responses got in #8638.
Current Behaviour
ResponseBuilder gzips the body and sets Content-Encoding: gzip, but never adds Accept-Encoding to Vary, neither on the compressed response nor on the plain one served to a client without gzip. A cache keyed only on the URL can store the gzipped body and serve it to a client that did not ask for gzip, or keep serving the plain body to everyone.
When compression is enabled for the route or the response, add Accept-Encoding to Vary, keeping any Vary value the route already set (as the CORS code does for Origin). I can open a PR.
Activity
leandrodamascena commentedon Oct 30, 2026
Thanks @anishmehta24, I agree, same reasoning we used for
Vary: Originin #8638. Reviewing #8711. Goes into 3.40.0.