by samarudge · 11y ago · 0 comments
I couldn't (quickly) find documentation on how to get the value of a specific cookie, but the server could send a user ID in a header or something Varnish can easily access to be used in the above function.
sub vcl_recv {
set req.http.X-Custom-Cookie-Value = regsub(req.http.cookie, ".*;|^)YOUR_COOKIE_NAME=([^;]+)(;.*|$)", "\2");
}
Then you can just: sub vcl_hash {
set req.hash += req.http.X-Custom-Cookie-Value;
}
And now you're cache segmented on that cookie value.https://www.varnish-cache.org/trac/wiki/VCLExampleRemovingSo...