MODX CDN integration

Introduction

MODX is an open-source CMS and application framework. It is able to provide you with a powerful framework to create your own secure web applications and sites. Here are some reasons why MODX is worth your attention:

  • It is free to download and use.
  • It is able to provide you with complete creative freedom.
  • It is secure and scalable.
  • It has amazing community and resources.

If you aren’t satisfied with your MODX online resource, use a CDN to speed it up. Below you will find some tips how to integrate CDN with MODX.

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 MODX using CDNsun MODX CDN plugin

  1. Log in to your MODX Manager.
  2. Go to ElementsPluginsNew Plugin as in the picture below.
    MODX New Plugin
  3. Fill in the plugin name and description as in the picture below.
    MODX Plugin Description
  4. Copy-paste the MODX CDN plugin source code from our GitHub.
  5. In the plugin's __construct method replace the default CDN domain 12345.r.cdnsun.net with your CDN domain.
  6. Go to System Events and tick the OnWebPagePrerender event as in the picture below.
    MODX Plugin System Events
  7. Click Save.
  8. 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.

Contact Us

 _    _    _    _     _  __  
| |  | || | || | ||  | |/ // 
| |/\| || | || | ||  | ' //  
|  /\  || | \\_/ ||  | . \\  
|_// \_||  \____//   |_|\_\\ 
`-`   `-`   `---`    `-` --`