what does this configuration in apache mean?

omg picture omg · Jun 9, 2009 · Viewed 11.4k times · Source
Header append Vary User-Agent env=!dont-vary

Can anyone give a detailed explanation for this?

Answer

Paul Dixon picture Paul Dixon · Jun 9, 2009

This uses Apache mod_headers to append the value "User-Agent" to the Vary HTTP header, but only if the dont-vary environment is not set.

But what is the Vary header? See RFC2616 which says

The Vary field value indicates the set of request-header fields that fully determines, while the response is fresh, whether a cache is permitted to use the response to reply to a subsequent request without revalidation

If you deliver different HTML markup depending on the User-Agent header, you might use a Vary header with User-Agent in it to ensure that a caching proxy didn't serve content intended for browser X to browser Y.