Skip to content

Set Vary: Accept-Encoding on GzipMiddleware responses #228

Description

@SyniRon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-agentFully specified, ready for an AFK agent to implement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions