LogoLogo
  • Welcome
  • Landing in Transparent Edge
  • Sign up process
  • Getting Started
    • Basics concepts
      • Glosary
        • API
        • Brotli Compression
        • Cache-Control
        • Cache key
        • Caching
        • CNAME
        • Cloud Computing
        • Cloud Computing Architecture
        • Cloud Services
        • DASH
        • Data Center
        • Edge Server
        • ETag
        • GSLB
        • HLS (HTTP Live Streaming)
        • HTTP/2
        • Infrastructure as a Service (IaaS)
        • Internet Exchange Point
        • Last-Modified
        • Load Balancing
        • MultiCDN
        • NoSQL (not only SQL)
        • Origin
        • Origin Shield
        • OTT (Over The Top)
        • Platform as a Service (PaaS)
        • PoP (Point of Presence)
        • Private CDN
        • Private Cloud
        • Public Cloud
        • Purge
        • Query String
        • Reverse Proxy
        • RTT (Round-trip Time)
        • SaaS (Software as a Service)
        • SDS (Software Defined Storage)
        • Smooth Streaming
        • Status Code
        • TCP (Transmission Control Protocol)
        • TLS Acceleration
        • TLS (Transport Layer Security)
        • TTFB (Time-to-first-byte)
        • TTL (Time-to-live)
        • Virtual Machine
        • VPS (Virtual Private Server)
        • Web Services
      • Let's start at the beginning
      • Things to consider
      • Houston, we have a problem
      • HTTP, How does it work?
      • Invalidating methods
      • DNS Pointing
      • Log formats
      • Predefined headers
      • Default headers
        • geo_country_code
        • X-Device
        • Vary
        • Cache headers
        • Age
        • TP-Cache
        • True-Client-IP and X-Forwarded-For
      • Forcing No-Cache
      • Architecture
        • Transparent Edge’s IP addresses
        • Locations and PoP
        • Cache layers
      • Cache effectiveness
      • SSL
      • HTTP 5xx Error Codes
      • Features
        • Protection against origin failures
        • Rate Limit
        • Geolocation and geoblocking
        • Prefechting
        • Refetching
        • Fast purging
        • HTTP Redirects
        • Caching static vs. dynamic objects
        • Rewriting of headers
        • Device detection
    • Dashboard
      • Historic
      • Analytics
      • Invalidating content
      • Content invalidation by tags
      • Prefetching Cache
      • Log shipping
      • Provisioning
        • Initial configuration
        • Backends
        • Sites
        • Configuration deployments
        • Network ACLs
        • TLS/SSL Certificates
      • User management
  • Configuration
    • VCL Reference
      • Default Functions
      • VCL Objects
      • Callable Functions
      • Security restrictions
      • Varnish book
    • Network Access Control List
      • Initial configuration
      • Auto generated lists
      • Manage lists via API
    • i3
      • Quality adjustment
      • Cache timing allocation for transformed images
      • Conversion to grayscale
      • Conversion to WebP
      • Blurring
      • Inclusion of graphics in the footer (strip)
      • Automatic resizing
      • Definition of the maximum size (content-length)
    • Transcoding
      • Relaunch or requeue jobs
      • Create a transcode job
      • Get job information
      • Dashboard usage
    • OpenAPI de TransparentCDN
  • Security
    • HTTPS
    • Blocking User-Agent
    • Blocking by IP Address
    • Blocking Requests Geographically
    • Avoiding Hotlinking
    • Bot Mitigation
    • WAF
      • Configuration
      • CAPTCHA
      • Content protected by token
      • Rate limit
    • Anomaly Detection
      • Detection Types
      • Automatic Reactions
      • Detection History
    • Under attack mode
    • Global Whitelists
  • Integrations
    • Wordpress plugin
    • Google Cloud Platform
    • Amazon Web Services
  • GUIDES AND TUTORIALS
    • How to do things
    • Edge Computing
      • ESI Tags
    • Acting on the Query String
    • Working with cookies
    • Making decisions based on HTTP headers
    • Web Application Gateway
    • Configure your servers to send cache headers
    • Caching a version per device
    • True-Client-IP in the origin
    • A/B Testing
    • Routing traffic to different backends
    • JSON Web Tokens
    • Debug codes
    • Streaming logs
    • API
      • Authentication
      • Invalidation
Powered by GitBook
On this page
  • What is A/B Testing and why would we want to implement it?
  • Solution

Was this helpful?

Export as PDF
  1. GUIDES AND TUTORIALS

A/B Testing

PreviousTrue-Client-IP in the originNextRouting traffic to different backends

Last updated 1 year ago

Was this helpful?

What is A/B Testing and why would we want to implement it?

Through A/B testing, we can expose users to two slightly different experiences, such as changing the color of a button in the interface. Then comes the analytical part for each variant, such as the percentage of "purchases" on the website, and we can decide which variant introduces a real improvement. provides a comprehensive explanation of the process.

Okay, this sounds good, but what about the performance and security offered by the CDN? Can we implement an A/B testing model without sacrificing it?

The CDN and its caching system (Varnish) cache the responses returned by the origin server completely, so most client requests do not reach the origin server. If the A/B testing system relies on logic located at the origin server, even if a client assigned to variant A requests the website, they could receive the cached opposite variant instead (and vice versa). This is not what we want, and any information obtained in the A/B testing experiment would be invalid.

Solution

In reality, there are multiple ways to solve this problem using the tools at our disposal. Let's see a simple example where we separate clients based on their IP address.

sub vcl_recv {  
    if (req.url ~ "^/carrito"){   
        set req.http.abtesting = "A";  
        if (req.http.True-Client-IP ~ "[0-2]$") {  
            set req.http.abtesting = "B";  
        }
        set req.http.X-Vary-TCDN = req.http.X-Vary-TCDN + ",abtest:" + req.http.abtesting;
    }  
}

In the previous example, we see how an abtesting header is set to distinguish between different variants. Then, based on the client's IP, we assign them a different variant. This could be done based on any other header or request parameter. In this case, we are balancing the variants with a split of 30% for "B" and 70% for "A", as the IPs ending in 0, 1, or 2 will be assigned to variant "B," and the rest to variant "A."

Lastly, we set the X-Vary-TCDN header, which is a special internal header that manages cache variants. It includes the value of abtesting and stores a different version of the object in the cache for each variant. This allows us to benefit from both the CDN and A/B testing.

As for the origin server, it only needs to serve the appropriate variant based on the abtesting header when a cache miss occurs.

This link