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
- Log in to your MODX Manager.
- Go to Elements → Plugins → New Plugin as in the picture below.
-
Fill in the plugin name and description as in the picture below.
- Copy-paste the MODX CDN plugin source code from our GitHub.
- In the plugin's __construct method replace the default CDN domain 12345.r.cdnsun.net with your CDN domain.
-
Go to System Events and tick the OnWebPagePrerender event 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.