Details
-
Improvement
-
Resolution: Unresolved
-
Medium
-
5.4.11, 2.0.2
-
None
-
Varnish and PROD env
Description
This issue relates this PR:https://github.com/ezsystems/developer-documentation/pull/193
Not sure if it is a bug.
When using Varnish, Vary on X-User-Hash is added all the time when the header is present in the request:
https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/1.3/EventListener/UserContextSubscriber.php#L180
if ($request->headers->has($this->hashHeader)) { ... if (!in_array($this->hashHeader, $vary)) { $vary[] = $this->hashHeader; }
which is the case all the time:
https://github.com/ezsystems/ezplatform/blob/master/doc/varnish/vcl/varnish4_xkey.vcl#L222
sub vcl_deliver { // On receiving the hash response, copy the hash header to the original // request and restart. if (req.restarts == 0 && resp.http.content-type ~ "application/vnd.fos.user-context-hash" ) { set req.http.x-user-hash = resp.http.x-user-hash; return (restart); }
> all requests pass here
My point is that the documentation is confusing as when we read it we expect to decide when the vary will be set.
*But with Varnish, we are not.*
In the eZ Kernel, (and with Varnish)
https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/Core/MVC/Symfony/Controller/Content/ViewController.php#L113
if ($request->headers->has('X-User-Hash')) { $response->setVary('X-User-Hash'); }
That is useless in this case. FosHTTP Cache is doing it.
> That is not for that reason we should remove it, as we could have scenarios that need it.
Although it is fine to me, to Vary all the time, it is not a bug, I don't see an issue with that BUT that is confusing not to know.
I have entered into a use case where I wanted to share an ESI between everybody (every user hash) and that is not possible easily because of that automatic vary.
I struggled because to me, you had to `->setVary` yourself, but again, you don't
In FOSHttpCacheBundle they have added an option `add_vary_on_hash` to allow that.
IMPORTANT NOTE: I did not really check with Symfony Proxy, but for sure in DEV mode the Vary is not set (as the Hash is not in the request)
Attachments
Issue Links
- relates to
-
EZP-31391 3.x forward compatibility: Provide abstracted way to vary by User Context hash
- Open