4 minutes reading time (860 words)

CDNs for Joomla - A Beginners Guide

CDNs for Joomla - A Beginners Guide

Ever wondered why pages load so fast on large sites? It's because they have good servers and use a Content Delivery Netowork (CDN). I use them on most of my sites and will explain what a CDN is, how it works, and how you can add one to your Joomla web site.

What is a CDN

A Content Delivery Network or CDN is a system of servers located around the world that serves images, CSS, Javascript and other file types to the site visitor. The advantage of a CDN is the visitor downloads the files from the physically closest CDN location. By shortening the physical distance between visitor and the web files, web pages load faster and visitors are happier.

There are many types of CDNs. Some specialize in images and static files, others specialize in audio and video. A Push CDN requires you to initiate the file transfer. A Pull CDN automatically transfers the files from the web server to the CDN. Most solutions are paid, there are a few free options available and all will make your pages load quicker.

Advantages

  • Pages load faster for a better end user experience
  • Reduces server bandwidth
  • Reduces server load

Disadvantages

  • Added complexity for your website setup
  • Can cause viewing errors for visitors if not configured correctly

How A CDN Works

To get a better idea how a CDN operates, lets go through the step by step process of a browser requesting and displaying a webpage. With and without a CDN.

For this example,  Let's Assume:

  • End user is in Germany
  • Web server is in Texas
  • Closest CDN location to end user is in France

Typical Website (No CDN Attached)

cdn-website-only-600

  1. The browser connects to the Texas web server and requests the HTML
  2. The Texas web server sends the HTML to the browser
  3. The browser requests the images / css / javascript from the Texas web server
  4. The web server sends the images / css / js to the browser

 

Website with CDN

CDN used with a Joomla website

  1. The browser connects to the Texas web server and requests the HTML
  2. The Texas web server sends the HTML to the browser
  3. The browser requests learns the images / css / javascript are at the French CDN and requests them
  4. The French CDN sends the images / css / js to the browser

From these two examples you can see how the web site / CDN combination has a shorter distance to travel and will display a web page faster.

How to add a CDN to Joomla

There are two main types of CDNs for static content, Push and Pull. Depending on your site setup one may be better than the other. A Pull CDN requires less initial setup and maintenance and is best for most Joomla sites. We will be working with a Pull style CDN.

First, create an account with a CDN provider and set up the DNS redirects. Your CDN provider will provide instructions. You will point cdn.yourdomain.com to point your CDN account.

Now that your CDN account and DNS is configured, it is time to move your images from www.mydomain.com to cdn.mydomain.com. One way to do this is to manually change all of your image URLs but this is a lot of work and not an efficient use of time. A better solution is to use a Joomla CDN plugin.

Joomal CDN plugins automatically change the links for all images / css / js from www.mydomain.com to cdn.mydomain.com. The better ones allow you to specify which file types should be rewritten and servered from the CDN and allow the use of multiple CDNs. By using a CDN plugin you can easily turn on and off the CDN.

Joomla CDN Plugins are located in the JED in the Core Enhancements >Performance > Content Networking category.

Three Popular CDN Extensions

For more information checkout this detailed Joomla CDN Extension comparison.

Living with a CDN

Okay so having your site attached to a CDN adds complexity. The most important thing is to remember that the images / css / js are coming from the CDN and not your web server.

When you are updating your site and the changes are not appearing, remember that the CDN is on. I often find it is best to temporarily turn off the CDN. Turning off the CDN removes any complications completely. Just remember to turn it back on when your updates are complete.

Another solution is log into your CDN control panel and purge the cache, then a fresh copy your files will moved to the CDN and appear in the browser.

Conclusion

I hope you have found this explanation of Content Delivery Networks helpful. A CDN requries extra configuration and extra expense but the benefits are well worth it. Especially if you have visitors located all around the world.

Have questions? Post them in the comments or find through any of the links in my Author bio and I will help where I can.

0
Joomla! 3.1 sortirà el 15 d'abril
Joomla! is the People
 

Comments

Already Registered? Login Here
No comments made yet. Be the first to submit a comment

By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/