November 12, 2015
This tutorial assumes you have already created a Pull Zone.
The CDN module add-on for Drupal will alter URLs, so your static content will load from the CDN servers, as opposed to your origin server. The module provides two modes: “Origin Pull” and “File Conveyor”. For setting up the site to use our CDN you need to only use “Origin Pull,” which is basically used as a domain name rewriting mode.
Installing Drupal CDN
- Login to your Drupal admin panel, click “Modules”, then click “Install New Module”.
- In the “Install from a URL” box, enter the CDN Module URL: http://ftp.drupal.org/files/projects/cdn-7.x-2.6.zip (check the official Drupal CDN Project Page for the newest stable version), and click “Install”.
- Now click on “Configuration”, then scroll down to click on “CDN”. In the “General” tab, tick the “Enabled” Radio Box then click “Save Configuration.”
- Click on “Details” then select “Origin Pull”. For the “CDN Mapping” box, enter the CDN URL in the following format: http://foo.bar.netdna-cdn.com
(please note that the URL should be replaced with the original CDN URL you have).
- Click “Save Configuration”.
Your website should now be using CDN services, and you can confirm this by reloading your website and viewing the page source. If your Origin URL is rewritten to the CDN temporary URL you are all set.
In some cases you will have to tweak some default Drupal functions in order to properly implement the CDN:
- Navigate to admin → settings → performance
- Enable normal caching.
- Navigate to admin → settings → advagg → config
- Disable “Enable Advanced Aggregation”, “Use AdvAgg in closure” and “Gzip CSS/JS files” then click “Flush AdvAgg Cache.”
- Navigate to admin → settings → advagg → bundler
- Disable “Bundler is Active.”
- Navigate to admin → settings → advagg → css-compress
- Disable “Compress CSS Files” and “Compress Inline CSS.”
- Navigate to admin → settings → advagg → js-compress
- disable “Compress JS Files”, “Compress Inline JS” and “Enable Packer.”
To ensure you implemented MaxCDN correctly, you can view the source code of any page to confirm that the CDN domain is being used for static assets instead of your origin domain. You can also use tools like pingdom, gtmetrix, webpagetest that can give you more detailed reports on your CDN implementation status.