For years we’ve been serving our tracking code (the GSTC) through a global Content Delivery Network (CDN) called CloudFront.
CloudFront replicates our GSTC across the world allowing us to deliver it in the fastest possible time to your visitors.
Our original setup meant CloudFront was loading our code from a minified, but uncompressed file on S3. Most modern web browsers support gzip compression to reduce bandwidth, and using the CDN pointing straight to S3 meant this couldn’t be enabled.
The solution? Using our NginX cluster as the CDN’s origin. That way, the CDN loads the tracker from our nginx cluster, which in turn loads it from S3 and compresses it before passing it to the CDN. The CDN then caches and distributes this compressed code to its edge locations.
The results have been much bigger than we first expected, reducing the CDN data transfer amount by 40% but also, more importantly, further improving load times for the tracker for website visitors.