Skip to content

Improve support for Vary response header - #704

Merged
RobertoPrevato merged 2 commits into
mainfrom
feat/vary-improvements
Oct 11, 2026
Merged

RobertoPrevato merged 2 commits into
mainfrom
feat/vary-improvements

Conversation

@RobertoPrevato

@RobertoPrevato RobertoPrevato commented Oct 11, 2026 •

Copy link
Copy Markdown
Member
  • Add a vary parameter to the cache_control decorator and to
    CacheControlMiddleware, to add field names to the Vary response header
    (e.g. @cache_control(max_age=60, vary=["Accept-Language"])). Names already
    listed in the response Vary header are not repeated (case-insensitive), and
    nothing is added when the response has Vary: *.
  • Fix GzipMiddleware to add Vary: Accept-Encoding to responses that are
    eligible for compression (also when not compressed for a given request), so
    that shared caches and CDNs do not serve a compressed response to clients that
    don't support it, or vice versa.

@RobertoPrevato
RobertoPrevato merged commit c032153 into main Oct 11, 2026
16 checks passed
@RobertoPrevato
RobertoPrevato deleted the feat/vary-improvements branch October 11, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant