This article shows you how to choose, register and configure a content delivery network (CDN) service, prepare a WordPress website and finally connect it to the CDN using a plugin.
A content delivery network improves the website speed, reliability, and security. It stores and serves the commonly requested web assets in cache servers located closer to the users. Most CDN providers have their data centers, known as Point of Presence (POP) or cache edge distributed globally, hence the ability to serve requests over shorter distances.
A nearby POP usually serves any visitor requesting for a cached object. However, if a user requests a new object not stored in the POP, the file is fetched from the origin server and cached to serve any other future requests.
As such, the origin server is only contacted when a file does not exist in the Point of Presence. The CDN then takes over and serves most of the static content. This reduces the load on the origin as well as the processing power and bandwidth requirements. Also, it reduces the direct contact with the origin server hence improving the security and preventing issues such as DDoS attacks.
Implementing a CDN is easy, and you can configure an essential service in only a few steps. Some web hosting providers integrate a CDN setup tool in their control panel. This is an automated process and requires little input when setting up. However, when this is not available, you can still set up the CDN in a few easy steps as shown below.
The process involves;
- Choosing a CDN provider,
- Registering and creating a zone on CDN servers
- Preparing and connecting the WordPress to the CDN.
Choose a CDN provider
Choose a CDN provider who meets your requirements. Factors that influence the choice include the ease of use, features, mode of delivery, cost, support and more. Some web hosting providers integrate CDN as a feature in their control panel. This is usually an easy to use one-click, automatic setup tool that configures everything and requires little input.
When looking for a CDN provider;
- Compare different CDNs and choose the provider who best meets your needs. Consider factors such as features, cost, presence, convenience, support, and more. The deployment procedure may differ from one provider to the other; however, there are some basic steps common to all of them as highlighted below.
- Look for low latency CDN, and depending on your target audience, one which is present closer to your visitors.
- Check location and number of Point of Presence: If you have a global audience, choose a provider with many worldwide Points of Presence (POP). If not, choose the provider with POP near your target audience. Below is a list of popular CDN providers.
- Google Cloud CDN
- Amazon Cloudfront
Register an account with the provider of your choice
After you have settled on your preferred CDN,
- Go to your provider’s website and sign up. (For the purpose of this article, we will use KeyCDN).
- Set up the pull zone, also known as distribution. The pull zone stores the files that the CDN serves to the users when requested.
To add the zone in KeyCDN,
- Log in to your account and click Zones.
- Type the name you want for your zone in the Zone Name box
- Choose the type of zone in the Zone Type box
- Type your website URL, in the Origin URL box.
- Save the settings.
The system takes a few minutes time to configure the zone. Wait until the status becomes Active, it also provides you with the Zone URL.. Once complete, you can now configure your website and point it to the zone.
The next step is to connect your WordPress to the CDN. You can do this manually, or using a plugin.
Integrate WordPress website with a CDN
There are different methods of integrating the WordPress to a CDN. You can either use a manual configuration or one of the many WP integration plugins. Some plugins are easy to use, and suitable for basic setups, while those with more customization are complex.
In this article, we will work with the WP Super Cache, which is simple and easy to configure. The plugin has the option to cache and serve static HTML content without querying the database, hence speeding up the performance. However, this works at the website server level. Besides this, the plugin allows you to easily integrate your website with a CDN of your choice, hence the ability to serve your visitors from an edge server POP near them.
Install and activate WP Super Cache
- Log in to the WordPress dashboard
- Click Add New under Plugins
- Type WP Super Cache in the search box and click the Search Plugins
- Install and Activate the WP Super Cache which appears in the search results.
Configure WP Super Cache
- Open the WP Super Cache plugin on the left-hand sidebar of the dashboard, under Settings.
- On the Easy Tab enable Caching On
- On the Advanced tab, you can select the recommended settings or tick the ones that will work best with your website.
Open the CDN tab
- Tick Enable CDN Support
- Type your website URL in the Site URL box
- Type the Zone URL from the CDN provider in the Off-Site URL box.
- Tick the Skip https URLs to avoid ‘mixed content’ errors box
- Leave the other fields with the defaults. However, these may vary according to your configuration at the CDN provider. But these should work fine for our simple configuration.
- Click Save changes.
A CDN is an effective way of improving the performance and security of a website by storing and serving static web components in cache servers located closer to the visitors. When integrating the CDN, you need to choose a provider who meets your requirements, register an account with the provider and finally connect your website to the CDN.
Integrating your website with a CDN is easy. Common methods include using manual configuration, a hosting provider’s CDN integration tool, or WordPress plugin. The choice of the integration method depends on the CDN provider, customization requirements as well skills level.
Check out these top 3 CDN services: