Introduction
OpenCart is an eCommerce platform which was designed to create eCommerce websites of various sizes. It is able to provide you with a ready-made eCommerce online resource without a need to write HTML code. Here are several reasons why to choose OpenCart:
- It is rich in various plugins.
- It is MVC (Model-View-Controller) based.
- It has a clear and easy to manage admin panel.
- You can use it free of charge.
If you want to provide your customers with good loading speed, you need to use CDN, read our instructions how to integrate CDN with OpenCart.
Before you start
- Before you take any steps please back up your files and database.
- In the following, we will integrate a CDN service using the CDN domain 12345.r.cdnsun.net. Please visit the Services/How-To section to obtain your CDN domain.
- To integate a CDN service on https:// website you can use https://12345.r.cdnsun.net or you can use a custom CDN domain with SSL enabled.
- If your website embeds custom fonts then please first enable CORS for them.
- Before you take any steps please make sure that your CDN domain is ready-to-use here.
Create CDN Static service
Please refer to Creating a CDN Static service for more details.
Enable CDN in Opencart using CloudCache extension
- Download the CloudCache extension.
- Upload admin and system folders to the document root of your Opencart website.
- Log in to the admin panel of your Opencart.
- Go to Extensions → Modules.
- Click on the install button on the right side.
-
Now we need to do two minor changes in the extension source code.
-
Open file /admin/controller/module/cloudcache_cdn.php, find private function validate and at the first line of the function body add.
private function validate() { return true;
Save the file.
-
Open file /config.php and at top of the file add.
<?php define('HTTP_IMAGE', 'http://12345.r.cdnsun.net/image/');
Save the file.
-
- Go back to Extensions → Modules
- Click the edit button on the right side of modules list in the CloudCache row.
- Enable the extension and fill in your CDN domain as in the picture below.
- Click Save.
- That's all.
Notes
- View HTML source code of your web pages to verify that you are using CDN, you should see source attribute of your images, CSS, JavaScript, etc. beginning with your CDN domain.
- Don't see your CDN domain in source code of your web pages? If your website is using any cache plug-in/mechanism then you might want to clear/flush its cache.
- Having troubles with custom fonts? Please refer to Using custom fonts with CDN - setting CORS for more details.
- Still having troubles? Check your CDN URLs in our CDN content check or please refer to Debugging a CDN service for more hints.