@@ -297,6 +297,10 @@ To enable this feature, add the following to ``your_varnish.vcl``:
297297 call fos_user_context_recv;
298298 }
299299
300+ sub vcl_hash {
301+ call fos_user_context_hash;
302+ }
303+
300304 sub vcl_backend_response {
301305 call fos_user_context_backend_response;
302306 }
@@ -314,6 +318,10 @@ To enable this feature, add the following to ``your_varnish.vcl``:
314318 call fos_user_context_recv;
315319 }
316320
321+ sub vcl_hash {
322+ call fos_user_context_hash;
323+ }
324+
317325 sub vcl_fetch {
318326 call fos_user_context_fetch;
319327 }
@@ -346,6 +354,13 @@ request with :ref:`a proper user hash <return context hash>`.
346354 set the ``req.url `` to a fixed URL. Otherwise Varnish would cache every
347355 hash lookup separately.
348356
357+ The ``fos_user_context_hash `` should be used to separate the cache of the
358+ hash lookup. If you don't do that, Varnish can run into performance issues
359+ because the user hash lookup creates a `large number of variants `_. If your
360+ hash is taking into account other headers than ``Authorization `` and
361+ ``Cookie ``, create your own ``vcl_hash `` function that adds all those
362+ headers to ``hash_data `` for user context hash lookup requests.
363+
349364 However, if you have a :ref: `paywall scenario <paywall_usage >`, you need to
350365 leave the original URL unchanged. For that case, you would need to write
351366 your own VCL.
@@ -470,5 +485,6 @@ To enable this feature, add the following to ``your_varnish.vcl``:
470485.. _ykey documentation : https://docs.varnish-software.com/varnish-cache-plus/vmods/ykey/
471486.. _Cache Invalidation chapter of the Varnish documentation : http://book.varnish-software.com/4.0/chapters/Cache_Invalidation.html#hashtwo-xkey-varnish-software-implementation-of-surrogate-keys
472487.. _installing xkey : https://github.com/varnish/varnish-modules#installation
488+ .. _large number of variants : https://github.com/varnishcache/varnish-cache/pull/3520
473489.. _`builtin VCL` : https://github.com/varnishcache/varnish-cache/blob/5.0/bin/varnishd/builtin.vcl
474490.. _`default VCL` : https://github.com/varnishcache/varnish-cache/blob/3.0/bin/varnishd/default.vcl
0 commit comments