Apache <if> directive leads to Vary: header entry

48 Views Asked by At

I am using a

<If "%{HTTP:X-Some-Header-here} == 'yes'">
    // Set some magic here
</If>

in my Apache (2.4) config.

This leads to a an "automatic" entry in the Vary: response header (if the stuff within the section applies) like

Vary: other stuff,X-Some-Header-here

Is there any simple way to deactivate this behaviour sine the X-Some-Header here is kind of "private" in my config?

I could do some magic with header rewriting but I hope there is a very simple directive to disable Apache to do this automatically.

Thanks :-)

1

There are 1 best solutions below

0
On

Use req_novary.

As stated in the apache documentation:

req_novary: Same as req, but header names will not be added to the Vary header

Vary header is automatically applied for the following headers:

  • HTTP_ACCEPT
  • HTTP_COOKIE
  • HTTP_FORWARDED
  • HTTP_HOST
  • HTTP_PROXY_CONNECTION
  • HTTP_REFERER
  • HTTP_USER_AGENT

In your case, this would be something like:

<If "%{req_novary('X-Some-Header-here')} == 'yes'">
// Set some magic here

Note for RewriteCond you can also use the NC flag