Agent Wranglers

WEB-43Recommended

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.

Examples

HTTP 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.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/performance/vary">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.