Implementing a content delivery network (CDN) is an effective way to speed up page load times, but what is a content delivery network, and how does it work?

When a request to load a webpage is made, the request starts at the user’s IP address, and through domain name servers the request is sent to the IP address of the server where that webpage is hosted.

If the user request starts in the UK, but the page is hosted on an Australian server, you can imagine that that’s quite a way for the request to travel. Plus, much like British Airways, the request can’t ‘fly direct to Australia’ (yet), it has to be re-routed at various server layovers on the way.

Intuitively, it makes sense that a server request from the UK to Australia will take longer to execute than one from the UK to Germany. Although, unlike in the example of aeroplanes, with server requests we’re talking a difference of milliseconds, not hours (or days).

A difference of a couple of hundred milliseconds might not sound like a major concern, but with page load times, an extra half a second could be enough for the user to hit the back button and abort the request. For ecommerce websites, studies have shown that an extra one second page load delay can cause a 7% reduction in conversions.

Okay, but what is a content delivery network?

Put simply, a content delivery network is a way of minimising the physical distance between the request and the server.

A content delivery network stores a cached version of the content that is being requested in various locations around the globe. These locations are called ‘points of presence’, or PoPs. These PoPs will all hold a cached version of the webpage.

When a request for the content is made, the CDN figures out where the request is coming from, and then looks for the PoP that is closest geographically to the IP address the request came from. This negates the need to send the request all the way from the UK to Australia, for example. Instead, the request will go to the nearest PoP to access the content. This minimised physical distance returns an improved page load time.

How does a CDN work? Push or pull?

There are two distinct configurations for CDN technology: push and pull. The main difference is the stage in the request process that the content is served to the CDN.

After setting up a pull CDN configuration for a web server hosted in the UK, the very first time a content request is made – say from Australia – the CDN has to figure out which PoP is closest, and then that PoP pulls the content from the host server, and then presents it to the user. From that point, the cached content is available on the Australian PoP to be served locally.

The difference with a push CDN is that the content is pushed out to the PoPs from the start, a push CDN doesn’t wait for the request to be made. The advantage of this is that the first user does not have to wait that extra step for the content to go from the host server to the local CDN.

However, it's worth noting that the additional delay on a pull CDN configuration is only for the first user in that geographic location. All subsequent users in the area are presented the cached version as normal. T

he disadvantage of a push CDN is that it requires extra configuration to keep content up to date. When updates are made to the website on the host server, there can be a delay of up to 15 minutes before the content is updated on all of the PoPs in the content network. In this time, a user would either see outdated content or a ‘file not found’ page.

Why use a CDN?

The most obvious reason is the described improvement of page load speed. It’s realistic that a four second page load time could be decreased to two seconds with cached content on a properly configured content delivery network. This has immediately obvious benefits for metrics such as bounce rates, page views and conversion rates. Remember – 25% of users will bounce if a page takes more than four seconds to load.

CDNs can also be used for load balancing. In cases where a webpage is seeing a surge in traffic, and content is all being pulled from the same PoP location because the surge in traffic is all local, a CDN can help manage this. For example, if the traffic is all coming from the UK, and being pulled from the UK PoP, the load on the PoP will increase, and so performance will decrease.

However, an intelligent CDN will begin to balance this load by redirecting traffic through, say, the German PoP. Although the latency will increase because there’s further physical distance between request and PoP, the page load time will remain lower because there is less load on the German PoP than there is on the UK one.

As well as the improved latency and page load times, CDN technology has other benefits. Because server requests are effectively coming through a proxy in the form of PoPs, there are certain security benefits to a content delivery network as well. CDN technology can be configured to protect from malicious requests like DDoS attacks. The CDN can tell if the request is malicious based on things like IP address and payload, as well as frequency and volume of requests. Because the CDN is ‘outside’ of the host server, it can block these requests and the host server will remain unaffected.

If you don't want to set up a content delivery network, it's still important to consider where your website is hosted. Cloud Servers from Fasthosts let you choose between servers in the UK, Germany, Spain and North America, so consider where most of your traffic will come from before choosing a data centre.