Agent Wranglers

Performance Recommended

Say which request headers change a response

Send Vary with every request header that changes a response, such as Accept-Encoding and Accept.

How to do it

Send Vary: Accept-Encoding on compressed responses. Add Accept wherever the same address can return different formats. An address that always returns one format needs no Vary: Accept.

Example

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Encoding: br
Vary: Accept-Encoding, Accept

How to check

curl -sI -H 'Accept-Encoding: br' on a compressed response shows Vary with Accept-Encoding. On an address that answers Accept: text/markdown with Markdown, both answers show Vary with Accept.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/performance/vary.