WordPress CDN: How to Boost WP Speed by Integrating a CDN?

WordPress CDN: How to Boost WP Speed by Integrating a CDN?

As the owner of a website powered by WordPress, both you and ultimately your users, want a fast website.

A slow website creates a bad impression of your company, and it has been proven that slow websites actually cost in terms of sales. Faster websites, on the other hand, increase the sales – the faster the website the better the sales.

If you want visitors to have a good their experience on your website, AND generate more sales in general, don’t just think about what the website looks like, but ALSO how fast your WordPress website performs.

In this post, we’re going to discuss one simple method of boosting your WordPress website’s speed with very little effort!

That involves using a CDN, or a Content Delivery Network. This is something which is commonly used by larger websites, but the benefits of using a CDN can be reaped by the website of all sizes.

Let’s have a deeper look at what a CDN is.

What is a CDN?

content-delivery-network

A content delivery network essentially consists of a network of servers which have been designed to deliver the content (of your website) in the most optimized way possible.

But how does a CDN make a WordPress website load faster than normal WordPress hosting services?

Basically, the network of servers used by the CDN is designed to handle the load of traffic of by spreading the load over a large number of servers, rather than a single server. We’ll be describing this in more detail later on in this article.

Most generic WordPress hosting services focus on a stable, generic environment which has all the necessary software for running WordPress, at the low possible cost to the hosting company and the client. These hosting server typically run generic Linux environments, with services such as Apache, Nginx, PHP, MySQL and other stacks of necessary hosting software.

Why is my WordPress site slow?

The reasons why the shared hosting services are typically not fast enough are various.

First, the environment is optimized and tuned for speeding up WordPress. In fact, shared hosting responds quite slowly, specifically in their initial response to a user request. This happens because each server hosts many websites together. This means that each website is competing with all other websites hosted on the server for resources – creating a resource bottleneck. This is done to keep costs as low as possible, but typically each website has to wait in a “queue” before it can be served – creating a degradation in speed.

Have a look at the below graph of a website hosted on a shared environment.

You can see that that website takes 1.34 seconds to start serving content.

While it may seem very little, this is an incredibly long time in reality. Bear in mind, that this is just waiting time – before the server even starts working on serving the site. This time is actually the time the request has spent in the queue, waiting for resources to be available.

Typically, one aims to have a website fully loaded in 3 seconds, such a delay means that it is impossible for the site to load quickly.

wp-cdn-demo

In general, the way to solve this problem is to opt for hosting services which are not shared, such as VPS servers.

The CDN Interface

But there are other ways to make a site faster, such as using a CDN.

But how does a CDN actually make a WordPress site load faster? It is all to the way the servers are set up, literally across the world.

Just like we discussed earlier, most websites are server from a single location. So if your website is hosted in the US, users from Europe will experience a speed degradation.

On the other hand, a CDN is designed as a network of hundreds of servers in different locations in different countries across the world. These caching servers or edge servers (as they are known technically) each have a copy of the images and files which your website uses.

See the diagram below from Incapsula CDN – one of the top providers, which shows the location of their servers across the world.

Global-infrastructure-of-caching-servers-of-Incapsula

Image: Global infrastructure of caching servers of Incapsula

When a user visits your website, the heaviest resources (images and static text files such as JS and CSS files) are served from the CDN server which is physically closest to your visitor, rather from your hosting server.

This makes a website much faster to load compared to if a website was not using a CDN because the heavy content needs to travel a much shorter distance now.

How a CDN makes a WordPress website faster?

Before we discuss how a WordPress site can be made faster with a CDN, let’s see the reasons why a website can be slow:

  1. The hosting server is hosting many websites together and response times are slow due to resource bottlenecks
  2. Large Images and CSS and JS files have not been optimized and take a lot of time to arrive from the web server to the visitor
  3. The many different WordPress plugins installed are generating too many CSS and JS files and other resources, slowing down the site
  4. The WordPress server is located a large physical away from the actual visitors of your website (e.g. the web server is located in in the United States, while many of your readers come from outside the US)

These are main reasons which cause a website to load slowlyA CDN typically resolves as much as 3 of the above reasons which are explained below.

WordPress Slow Loading – Issues and Solutions

# Issue 1: Your shared hosting is overwhelmed and slow.

We’ve already discussed how shared hosting services have resource bottlenecks because they are designed to be cheap, rather than fast.

The below diagram shows (on the right) what a website hosted on a shared hosting server looks like, while on the left we can see that such services as Cloud Hosting or VPS servers have dedicated resources for each website.

vps-hosting-vs-shared-hosting

To make your WordPress website faster, you should consider choosing from the best WordPress hosting or managed WordPress hosting companies, the ones with known good service and great reviews. The cheapest hosts should be avoided.

You should also buy the top plan you can afford. For example on my website, CollectiveRay, we use a VPS, which is typically a good balance between cheap shared hosting service and a dedicated server, which is fast but expensive. A VPS has dedicated resources to be able to start serving your WordPress site within a few milliseconds.

You can see the result of using a VPS below, the initial response time is less than 400 milliseconds:

cdn-used-website-example

But besides choosing a better plan for your website, by implementing a CDN on your WordPress, you are taking away a lot of load away from your server, because the heaviest resources are now hosted by the CDN.

# Issue 2: The images of your site are not optimized.

Images are also the main reason why WordPress websites can be slow to load. Too many images, which have not been optimized are catastrophic for loading times, especially without a CDN.

It’s very good advice to use images on your website, they are good for user experience because they make for much better reading.

In terms of explaining concepts or ideas, “An image is worth a thousand words” – so by all means, do use images.

But images can create problems with website loading speed.

Images which have not been optimized for fast loading times (i.e. reduce their size) will cause your website to load slowly, especially if you are not using a CDN, thus compounding the problem of heavy images.

So how do we solve this problem? Is there a way which can automatically optimize images making them smaller, and thus faster to load.

CDNs can address this problem without requiring any additional manual intervention. Image optimization (such as lossless compression) is usually a feature which is available as part of the service of most CDNs.

# Issue 3: WordPress plugins are creating lots of scripts and CSS files.

This is another problem which has a significant effect on the loading speed of a WordPress website.

Most WordPress users install all the plugins they think they need. Sometimes they are necessary, for a website. However, each WordPress plugin which is installed has an impact on the speed of your website – each plugin adds more CSS and JS files, making it load slower.

The fewer plugins you install on your website, the better for the speed of your site.

The below screenshot is from a WordPress website which has not been optimized for speed.

slow-website-performance-details

How to resolve these problems by using a CDN?

  1. Keep WordPress plugins installed to a minimum
  2. Reduce the overhead by combining the JS and CSS files into a few files only
  3. Serve your website over the fast and efficient HTTP/2 protocol

While the first depends on the WordPress owner, a CDN can help with the latter two i.e. the combining of files and delivering that content of the site over HTTP2.

CDN services typically perform compression and minification of JS and CSS files; making the website faster to load.

CDN services can also enable your website to be served over HTTP/2, simply by enabling a simple setting.

Since HTTP/2 requires that HTTPS has been enabled on your site, CDNs support the serving of content over HTTPS. CDNs allow you to enable HTTPS without having to fork out for the cost secure website certificates.

Besides that, most CDNs implement an efficient SSL/TLS handshake to ensure that even with HTTPS enabled – the site does not get a performance hit (something which might happen with shared hosting servers).

Some of the more popular CDN services are Incapsula, Cloudflare, and MaxCDN though there are several others.

How to set up a CDN for your WordPress (free or premium)

While you might think that CDN services are expensive, in reality, they typically offer a free plan. Most small websites get enough functionality from the free plan.

As the revenue from your website grows beyond the free plan, you can then move to a higher plan.

The simplest way to set up a CDN for WordPress does not even need a plugin since it just uses a reverse proxy – this means that the CDN is actually serving your site’s contents completely. It only refers to the shared hosting server for any dynamic content required.

This setup of this for WordPress only requires you to perform minimal changes to the DNS settings of your website. While most CDNs will provide exact guides on how to do this, you can also get support to do this from the CDN services.

Below we’ll explain briefly how a CDN with a reverse proxy works to serve a WordPress website.

The origin server in the diagram below is your website’s hosting server.

cdn-server

As we explained before, it is the CDN server which is closest to your visitor which actually receives the hit when a user visits your website. It then forwards the request to your site, for any dynamic content. Once the server replies, the CDN serves the dynamic content plus all static resources to the visitor.

This implementation of CDNs removes a lot of load from your website, which means that besides making your WordPress website load faster, it will be able to handle much more visitors.

Setup a CDN using a WordPress plugin

The alternative way of setting up a CDN is by using a WordPress plugin. Essentially, what this does is rewrite the address of static resources (e.g. images) such that they are served from the CDN server.

As you are setting up your CDN with a WordPress plugin, you will be provided with a URL which will be the location from where the static files of your site will be served.

For example,

https://www.website.com/images/logo.jpg

is now rewritten and served from as

https://cdn.website.com/images/logo.jpg

Just like with the previous setup using a reverse proxy, you still need to perform a few slight changes to the DNS entries of the domain of your website. This is necessary so that cdn.website.com, which is the root address of the CDN will resolve as the URL provided by your CDN.

See the example below of DNS entry for a website.

dns-entry

In terms of CDN plugins, the most popular one is the CDN Enabler plugin. This plugin is supported by KeyCDN, MaxCDN or Incapsula.

cdn-enabler-wp-plugin

Once you’ve set up this plugin on your WordPress, simply enter the URL given to you by the CDN service. This should be enough to get your website served through a CDN.

cdn-enabler-wp-plugin-settings

Conclusion

So, we conclude that CDNs are an easy solution to make WordPress faster. 

As we’ve seen in this post, implementing a CDN can improve the speed of your website in various ways. It’s also not expensive to get started with a CDN. Besides being free, your website will be faster, and you will give your visitors a better user experience for your visitors.

If you’re looking to have a boost your WordPress website’s speed, a CDN is a way to go.

Author Bio

David Attard, Founder of CollectiveRay has many years working in web design, with WordPress and other systems. His experience working in the online tech world allows him to find a perfect balance between technology and business objectives using digital marketing techniques.

(This is a guest post. View guest posting guidelines.) 

mm

ThemeGrill Author

We are a team of SEO copywriters and editors who work both individually and in the team. ThemeGrill author is where one of the editors here is working on one project personally or editing the guest posts. Write us @themegrill_blog in Twitter and +ThemeGrillBlog on Google+.

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest