Varnish: Remove all Cookies EXCEPT the ones you want
So, you’ve got a web server. It’s slow.
So, you optimize your app, and implement some caching. It’s faster, but not fast enough.
So, you decide to use Varnish, the popular reverse-proxy web application accelerator. It doesn’t work.
Well, client-side cookies are for the JS on your site; your application doesn’t actually care about them. BUT – and this is an annoying “but” – if those client-side cookies are set for “yourdomain.com”, then with every single request a reader makes to your server, those cookies are sent along.
And that means Varnish won’t cache anything, because it says, “Cookies?! EEK! No caching!”
So, how do you make Varnish happy with only the cookies that you want to keep?