The SecureCDN module for Drupal alters URLs so static content loads from CDN servers instead of the origin server. After completing this tutorial, static content will be delivered from StackPath CDN.
This tutorial assumes a site is created
Configuration
The CDN module for Drupal provides two modes: Origin Pull and File Conveyor. For setting up Drupal to use StackPath CDN, use Origin Pull. This mode is used as a domain name rewriting tool.
-
Log in to the Drupal admin panel. Select Modules, then select 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, then click Install.
-
Select Configuration, then scroll down and select CDN. In the General tab, tick the Enabled radio box, then click Save Configuration.
-
Select Details, then select Origin Pull. For the CDN Mapping box, enter your CDN URL in the following format: http://site.company.stackpathdns.com
-
Replace this example URL with the CDN URL for your site.
-
Click Save Configuration.
The StackPath CDN should be properly integrated into Drupal. To test, view the source code of any page to confirm that your CDN URL is being used to deliver static assets. For example, for a given image, instead of seeing yourdomain.com/images/photo-270/ you should see http://site.company.stackpathdns.com/photo-270/.
If the CDN domain is not present, follow the steps below. In some cases, changing default Drupal functions is needed.
Further Configuration
-
Navigate to Admin → Settings → Performance.
-
Enable Normal Caching.
-
Disable Page compression, Block cache, Optimize CSS files and Optimize JavaScript files, then select Clear cached data.
-
Navigate to Admin → Settings → Advagg → Config.
-
Disable Enable Advanced Aggregation, Use AdvAgg in closure and Gzip CSS/JS files, then select 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
View the source code again. The CDN URL should now precede the file name of all static assets.