GzipMiddleware negotiates compression on Accept-Encoding but never sets a Vary: Accept-Encoding response header. A shared cache in front of the service (the nginx proxy cache, a CDN) keys on the URL alone, so it can hand a gzipped body to a client that did not advertise gzip, or the reverse, because nothing tells it the response varied by encoding.
This is pre-existing and now covers both surfaces the middleware fronts:
Surfaced during the #227 review.
Why this is its own change:
- The header belongs in
GzipMiddleware (rest/gzip.go) so both surfaces pick it up from one place.
- Adding a response header changes the
/api wire contract, so contract/goldens/ (and openapi/openapi.yaml if it documents response headers) need updating in the same change.
- Worth confirming what the nginx layer already does with
Vary and cache keys, so the header actually changes behavior in production rather than being cosmetic.
Not urgent.
GzipMiddlewarenegotiates compression onAccept-Encodingbut never sets aVary: Accept-Encodingresponse header. A shared cache in front of the service (the nginx proxy cache, a CDN) keys on the URL alone, so it can hand a gzipped body to a client that did not advertise gzip, or the reverse, because nothing tells it the response varied by encoding.This is pre-existing and now covers both surfaces the middleware fronts:
/apiresponses (the chain inrest/rest.go).DocsHandlerin the same middleware.Surfaced during the #227 review.
Why this is its own change:
GzipMiddleware(rest/gzip.go) so both surfaces pick it up from one place./apiwire contract, socontract/goldens/(andopenapi/openapi.yamlif it documents response headers) need updating in the same change.Varyand cache keys, so the header actually changes behavior in production rather than being cosmetic.Not urgent.