Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Say hello to redesigned Cloudways, an empowering Startup Program, enhanced Staging, a new Let’s Encrypt Wildcard SSL certificate feature, and more. GET STARTED

Integrate Cloudways CDN with CodeIgniter Projects

Updated on October 26, 2017

3 Min Read
Reading Time: 3 minutes

Content Distribution Network or CDN has become an important aspect of website design. Given the global nature of the audience, a CDN is invaluable in ensuring fast page load speed for all visitors, regardless of the location of the visitor.

cdn in codeigniter

A CDN stores a copy of the static elements of the website on a series of servers called nodes. When a user requests a web page, the static elements are served from the nearest node of the CDN. This reduces the page load time significantly.

The good news is that you could easily integrate CDN within your CodeIgniter projects built on any PHP MySQL Hosting. This tutorial will guide you through the process of installing CloudwaysCDN on a Codeigniter project hosted on Cloudways.

The first step is the launch of a server and a PHP application on Cloudways. For more details on this, please check out the following GIF:

Login to your server and go to the Applications tab. Click the PHP application. Once the new screen opens, the tab for configuring CDN at the end of the options in the left-side panel.

Once you click the link, you will be redirected to the CDN screen where you could get the newly generated URL which will be used in the code application.

Now you need to extend the existing cdn_base_url function by overwriting it.

For this, start by creating the file: application/helpers/cdn_helper.php

This code will overwrite the cdn_base_url function to support and load the website assets from loading your asset from the key based CDN.

The next step is setting up the CDN URL. For this, you need to modify this file: applicaiton/config/config.php. Add the folloing line into the file . Remember to replace the cdn based url with the proper URL:


Here is the output in action:


In this tutorial, I discussed how you could integrate CDN with your CodeIgniter project. If you need help with the process, do leave a comment and I will get back to you.

Share your opinion in the comment section. COMMENT NOW

Saquib Rizwan

Saquib is a PHP Community Expert at Cloudways - A Managed PHP Hosting Cloud Platform. He is well versed in PHP and regularly contributes to open source projects. For fun, he enjoys gaming, movies and hanging out with friends. You can email him at

Create PHP websites without the worry of server management.

Deploy your PHP app on optimized PHP hosting servers.

Get Our Newsletter
Be the first to get the latest updates and tutorials.