Problem
The key does not include any request header. A route whose response depends on Accept-Language, Accept or Accept-Encoding serves whichever variant was cached first to every client. Setting Vary on the response tells downstream caches, but not our own backend.
Proposal
Add @cache(vary=["Accept-Language"]):
- Append each listed header's value (normalised: lower-cased name, trimmed value, missing as empty) to the key, encoded with
escape_key_component.
- Add the same names to the response's
Vary header.
- Header values are client-controlled, so document that each listed header multiplies the number of entries. Consider an optional allow-list or normaliser per header, e.g. to reduce
Accept-Language to a supported locale.
Additive; routes without vary keep their keys.
Problem
The key does not include any request header. A route whose response depends on
Accept-Language,AcceptorAccept-Encodingserves whichever variant was cached first to every client. SettingVaryon the response tells downstream caches, but not our own backend.Proposal
Add
@cache(vary=["Accept-Language"]):escape_key_component.Varyheader.Accept-Languageto a supported locale.Additive; routes without
varykeep their keys.