Web Hosting

Why Use a Content Delivery Network?

Most business website owners would agree that delivering their website content to visitors’ screens quickly is very important, so they use various tips and tricks to speed up their web pages. In the past, a common trick was to serve images from a separate subdomain, such as images.yourdomain.com, because browsers could only open a limited number of connections to each domain. Modern browsers and the HTTP/2 protocol have largely removed that limit, but one technique still makes a big difference: a content delivery network (CDN).

Benefits and Functionality

The main benefit of using a CDN is that your content is served faster, wherever your visitors are. For example, if your server is in your own country and a visitor is on the other side of the world, it takes that visitor’s browser longer to download your pages than it takes a visitor nearby. The delay is caused by the distance and the large number of “hops” needed to deliver the content: the data is routed through many devices on the network before it finally arrives. A CDN, on the other hand, copies your content to data centers around the world and serves each visitor from the closest one, ensuring faster delivery.

Affordable CDNs for Small Business

CDNs are not just for large companies. There are solutions to suit the needs and budgets of smaller businesses too. Many web hosts now include a free CDN with their plans, and Cloudflare offers a popular free plan that you can set up by pointing your domain to it. Another well-known option is Amazon CloudFront, which works together with Amazon S3 (Simple Storage Service): S3 stores your content and CloudFront delivers it quickly to visitors in different locations.

How to Set Up Amazon CloudFront and S3

After signing up for an Amazon Web Services (AWS) account, upload your website’s static files, such as images, to an S3 “bucket”. Then create a CloudFront distribution in the AWS console and choose your bucket as its origin. CloudFront can keep the bucket private and fetch the files from it securely. To serve the content from your own subdomain, such as cdn.yourdomain.com, add the subdomain to the distribution along with a free SSL certificate from AWS Certificate Manager, and create a CNAME record in your DNS settings that points the subdomain to your CloudFront address. Your content is now ready to be served from your CDN.

More Than Just Speed

A CDN does more than make your pages load faster. Because it serves copies of your files from its own servers, it takes a lot of the load off your web host, which helps your site stay up during traffic spikes, such as when a post goes viral or a sale starts. Many CDNs also include protection against distributed denial-of-service (DDoS) attacks, a web application firewall that blocks common hacking attempts, and free SSL certificates.

Do You Need a CDN?

A CDN is especially worthwhile if:

  • Your visitors come from many different countries or regions.
  • Your pages include lots of images, videos or downloads.
  • You run an online store, where every second of loading time can cost sales.
  • Your traffic is unpredictable, with occasional big spikes.
  • You want an extra layer of security in front of your website.

If your website is small and nearly all your visitors are close to your server, you’ll see a smaller benefit, but with free plans available, it can still be worth turning on.

Check That Your CDN Is Working

Once your CDN is set up, make sure it’s actually serving your content. Open your site, then use your browser’s developer tools to look at the response headers for your images and other files. Most CDNs add a header showing whether a file was served from the cache, such as cf-cache-status on Cloudflare or x-cache on CloudFront. A free speed test, such as Google PageSpeed Insights, can also show you how much faster your pages load.

Common CDN Settings to Know

  • Cache lifetime: how long the CDN keeps a copy of each file before checking for a newer version. Images and stylesheets can usually be cached for a long time.
  • Purging the cache: after you update your site, clear (purge) the CDN’s cache so visitors see the new version straight away.
  • Compression: most CDNs can compress files automatically to make them smaller and faster to download.
  • Image optimization: some CDNs resize and convert images to modern formats such as WebP on the fly.

One of the most important qualities of any website is performance. If your web pages take too long to load, visitors will leave, sales will be lost and the whole experience will be unsatisfying. A slow site can also hurt your rankings, because page experience, including speed, is one of the signals Google uses. With a content delivery network, you can offer a fast experience to every visitor, wherever and whenever they visit.