1

I have a test server running CentOS, and changing the Vary header there through PHP via:

header('Vary: Accept');

works as expected (it's added to the Accept-Encoding value that Apache already adds by itself). On the Ubuntu 10 LTS production server it does not. I tried to search the web for answers, but couldn't find any. Even setting:

header('Vary: Accept',true); // forces the header to be replaced

won't change the Vary header. Any help would be appreciated.

The server is running Apache/2.2.14 (Ubuntu) and PHP/5.3.2-1ubuntu4.26.

  • You state Vary: Accept, but mention Accept-Encoding - shouldn't you be sending Vary: Accept-Encoding in this case? "it's added to the Accept-Encoding value that's being set by Apache" - what do you mean by this? The Vary: Accept header tells the local cache to take the Accept header into account when caching a response. – MrWhite Sep 4 '14 at 10:42
  • @w3d: I didn't explicitly set the Accept-Encoding part, so it must have been Apache itself, because I've set up mod_deflate. – DanMan Sep 4 '14 at 16:30
  • Ah OK, thanks for clarifying (I think I must have read it wrong earlier!) – MrWhite Sep 4 '14 at 16:46
2

Check if you have the environment force-no-vary set to TRUE in your configuration, or simply try to set it to FALSE in your virtual host configuration. More details about this and how you should proceed, you can fine here: Environment Variables in Apache.

Also, there are modules that may override this header when the response is served to the client - for example, mod_deflate, but as you mentioned, you don't get this header back at all so my best guess remains the force-no-vary environment setting.

  • I do have mod_deflate activated on both servers. But only on the CentOS one I can add more values to it, not on the Ubuntu one. I'll try the env-var. – DanMan Sep 4 '14 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.