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:
- Affiliate URLs contain ?a=x, where x is the id of an active affiliate. A list of affiliates can be found here.
- 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.
- Phoenix handles the link and serves up an affiliate cookie and a redirect .
- Because the response contains a cookie header, Varnish does not cache it. So affiliate links (URLs with ?a=x) are never cached in Varnish.