Multiple Vary headers emitted #1064
Comments
Not sure if related, but i was having this issue when i had: gzip_vary on; in my http block, instead of the server block. |
@jeffkaufman is this worthy of being on the work-prioritization list? |
Added |
Reminder, please.. would love to have this fixed too (request of one of my clients). 😃 |
Same issue here. I'll follow the thread in case of updates :) |
Fix for this is in progress at https://github.com/pagespeed/ngx_pagespeed/tree/oschaaf-trunk-tracking-issue-1064, working on tests to prevent regression. |
The report from some time ago mentioned three Vary: headers, but I can now only reproduce two using trunk-tracking plus the original repro-configuration. This fix unflags r->gzip_vary as set by the gzip module when PSOL hands us Vary: Accept-Encoding, to make sure that nginx's core header filter doesn't append another one. Fixes #1064
@oschaaf thanks, I applied the patch successfully (without errors) and recompiled Nginx with it. First time:
Second time:
Just try it yourself, change qver=1.11.4 to qver=1.11.5 or 6 or what you want, it's just a variable. The double Vary headers appear after the 2nd access. It's only with rewritten sources, normal sources are fine:
I've purged all the caches (pagespeed via memcached) and gave the whole VPS a reboot to make sure not battling with the caches, but still no avail. Let me know if you need more information. |
It took me a little while, but I found the old directory where I could reproduce writing out three Applying #1105 there, the number of The two remaining What is surprising is that your website continues to emit three Vary:Accept-Encoding headers with #1105 applied: I would at least have expected one of them to be removed.. Which makes me wonder: how did you clear PageSpeed's caches? The "official" way or by directly purging the memcached instance(s)? |
@oschaaf yes, strange isn't it? I cleared the cache by deleting the files inside /var/cache/ngx_pagespeed and I rebooted the server (so memcached would be 100% fresh and empty too). |
@HansVanEijsden: Are you sure you fired up the patched nginx binary? Is it possible that the old (unpatched) nginx server was/is still running? I can't yet come up with a reason that would explain how it could be that the patch has zero effect, but there may be something in your configuration or module list that bars the patch from working correctly (though even if the patched worked, the problem would persist but in reduced form, because ngx_pagespeed would also need to be build against a newer PSOL version to eliminate the problem completely). If you are sure we're looking at a patched nginx instance, what does |
@oschaaf unfortunately.. yes, I'm sure about that. I installed ngx_pagespeed following the instructions in #1099 and I also applied the cherry-pick.
After re-installing nginx I gave the whole server a reboot, to make really really sure no old binaries to be active.
I sent you my config files by mail. 😃 |
Thanks @HansVanEijsden |
@oschaaf I own you a beer. |
There are two |
@nirocfz @JoyceBabu You can find the patch @HansVanEijsden used here. |
@oschaaf That's great! |
@JoyceBabu the gist I posted should apply cleanly when b081bb7 (#1105) is not cherry-picked. |
Thank you @oschaaf. I have successfully applied the patch, and now there is only one Vary header. |
After updating to 1.10.33.5 the issue still persists. I had to re-apply this patch to make it work. |
I just switched to using downstream proxy cache and 1.10.33.5 as a dynamic module and seeing 3 sets of Vary: Accept-Encoding headers and yes only with rewritten pagespeed resources as well
using CentOS 6.7 and 7.2 for my site at centminmod.com and I also have ngx_brotli and other modules enabled
I also have gzip_vary on only in http block and not each vhost block |
For fixing this we would need to land #1105 (pending review) plus a commit on the mps side but I am not sure which one.. |
-ps- the patch link I posted in a gist above (https://gist.github.com/oschaaf/c16c7458a57db4e94323) is similar to #1105 but adds a temporary hack to make sure ngx_pagespeed only emits a single vary header when psol hands it more then one. |
I don't know if it's by purpose, but I receive Pingdom errors about Vary headers (I applied the patch), because sometimes there are 2 different Vary headers at the same time: "Vary: Accept-Encoding" and "Vary: User-Agent".
Turning Pagespeed off fixes it:
The correct one would be: "Vary: Accept-Encoding, User-Agent". |
@HansVanEijsden As far as I know at the http level
means the same as
From https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
|
@oschaaf thanks! I will pass that on to Pingdom. |
Sorry for the super noob question but how do i apply this patch without it failing?
|
@deweydb no worries, there are no stupid questions, only stupid answers. I do it like this: Good luck! |
I just reproduced this on www.jefftk.com:
And then:
(This is after I merged #1105 but I didn't rebuild jefftk.com so that bug is still there.) We see: 1st response: one vary header. The 1st response is correct, and for the later responses not having #1105 merged means one extra one is expected. So there's two unexplained vary headers on the 2nd response, and one unexplained on later responses. Trying to fix this now. (Thanks for @morlovich for having a good sense of where to look!) |
Even though I have this replicated on jefftk.com, I'm still having trouble replicating it in a dev environment. Still working on it. |
Talking to @oschaaf , neither of us have been able to reproduce this with current PSOL, just on the 1.10 branch. It looks like this will be resolved the rest of the way when we next cut a branch (1.12 if it exists, otherwise 2.0) and it's not worth putting additional time into for now. |
The report from some time ago mentioned three Vary: headers, but I can now only reproduce two using trunk-tracking plus the original repro-configuration. This fix unflags r->gzip_vary as set by the gzip module when PSOL hands us Vary: Accept-Encoding, to make sure that nginx's core header filter doesn't append another one. Fixes #1064
The report from some time ago mentioned three Vary: headers, but I can now only reproduce two using trunk-tracking plus the original repro-configuration. This fix unflags r->gzip_vary as set by the gzip module when PSOL hands us Vary: Accept-Encoding, to make sure that nginx's core header filter doesn't append another one. Fixes #1064
I thought this was fixed in 1.11.33.0 ? from proxy downstream front end
from proxy downstream backend
nginx configuration
|
Sorry @centminmod , only half of this fix is in 1.11. Specifically, b081bb7 resolved this for most users, but for some users we have unreleased changes on master to clean up the rest of the duplication. That will be in 1.12 (if it's needed) or 2.0. |
@jeffkaufman thanks for the clarification.. looking forward to 1.12/2.0 :) |
On trunk-tracking, we somehow end up emitting three
Vary: Accept-Encoding
headers.$ curl -I -X GET http://192.168.137.10:8090/mod_pagespeed_example/styles/index_style.css HTTP/1.1 200 OK Server: nginx/1.8.0 Content-Type: text/css Connection: keep-alive Vary: Accept-Encoding ETag: "5666b969-2c7" Accept-Ranges: bytes Date: Wed, 09 Dec 2015 15:51:53 GMT Expires: Wed, 09 Dec 2015 15:56:53 GMT Cache-Control: max-age=300 X-Original-Content-Length: 711 Vary: Accept-Encoding Vary: Accept-Encoding Content-Length: 711
nginx.conf:
The text was updated successfully, but these errors were encountered: