How affiliate cookies work with Varnish


Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /homepages/46/d762693627/htdocs/dc/includes/
How affiliate cookies work with Varnish

Types of affiliate links

Affiliate links can take two forms, for example:


The first of these uses a query string (?a=123456) and as we usually strip out query string in Varnish, we need to treat this as a special case (see below).

The second of these is treated the same in Varnish as any other link, however because the response contains a "set cookie" header, Varnish does not cache the response.

Varnish and affiliate links with query strings

Here's what happens when guests view our site using an affiliate link:

  1. Affiliate URLs contain ?a=x, where x is the id of an active affiliate. A list of affiliates can be found here.
  2. Varnish strips out many query strings from incoming requests, so that URLs with Google tracking ids etc are not cached uniquely in Varnish. However these modifications only work on a small whitelist of patterns, so affiliate links are NOT affected. In other words, the ?a=x bit still makes it though to Phoenix.
  3. Phoenix handles the link and serves up an affiliate cookie and a redirect .
  4. Because the response contains a cookie header, Varnish does not cache it. So affiliate links (URLs with ?a=x) are never cached in Varnish.

Related issues

blog tag: