Edge Caching and Content Distribution Networks

13 Nov

Where is my store hosted, and will it perform quickly for customers in country XYZ ?

Our support team get asked that question a lot, and the answer to the first part is that stores are hosted in the UK (at the moment)  The answer to the second part isn’t quite so simple, but the great news is that we’ve ensured that it will perform quickly for customers all over the world.  Lets take a look at how we’ve managed to achieve this.

Latency is a problem as old as the internet itself.  The internet has no international boundaries as far as your customers are concerned, so where do you choose to host your site ?  Thankfully, there are some pretty cool solutions to this problem, and at FreeWebstore we’re using a global Content Distribution Network (CDN) to ensure that your customers can access your content on a server hosted as near to them as possible.  Here’s a brief overview of how it works;

A client accesses your store using their browser, which grabs all of the elements necessary to render that page in their browser.  These elements are generally the following;

  1. HTML
  2. Images
  3. CSS
  4. Javascript

There can be more, but let’s focus on these for now.  Usually the way these things are setup, all of the above elements are on the same server, in the same country, in the same location.  This works fine if you’re near to that location, but what if you’re on the other side of the world ?  Surely that’s going to be slow, as the data has further to travel, with more routers and switches to pass through until it gets to it’s destination.  This is true, and the solution we’ve deployed is to cache all of the high bandwidth, static elements of your store really close to your customers, so that they only have to make those long round trips for small, dynamic elements.  In most cases, this means that elements 2, 3 and 4 of the list above are being grabbed from servers in the same country as the client.  In a lot of cases, they’ll even be in the same region.

So those big images, that CSS that doesn’t really change all that much, and all of those lovely JavaScript widgets you’ve installed on your store load in a snap.  All the browser has to do then is grab the relatively small chunks of HTML, that our systems have dynamically generated and put it all back together, resulting in a very snappy experience all round.

There is essentially a global network of servers that we use, in locations almost everywhere you can think of.  When the browser in a country requests a particular file, it’s automatically routed to it’s closest server location.  If that server doesn’t have the file yet, then it puts a request in back to our origin servers, gets the file from there, and keeps hold of it.  The next time somebody from a similar location requests the same file, from the same server, it already has it and gives it to them at lightning speed.  If you know how the cache or “Temporary Internet Files” in your browser works, it’s a bit like that … on a global scale !

Hang on a sec, you said it keeps it for a while.  What if I want to change that file ?

That’s a very good point.  One of the downsides of such a system, is that cached files, while providing great performance, can get out of date.  We do cache files for a long time so that we can focus on performance, but they will eventually expire, even if it takes a week, and the cache will grab the latest version from the origin.

Luckily, this is pretty easy to work around using versions in file names.  With an image, for example, if you want to change it, you just upload it with a different file name.  If you then update the links to the old image and change them to the new image name, the cache doesn’t know anything about this new file, so it will come back to the origin to get it and boom !  It’s updated, and cached for the next user who wants it.  As far as CSS and JavaScript goes, we take care of most of that for you, but it works in a similar fashion.  Whenever you make a tweak to your store via your FreeWebstore Control Panel, we will automatically re-version the file for you, so that the caches come back for the latest files and your brilliant new design change, widget or small tweak will be shown to your customers instantly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: