Drupal CDN Integration
Drupal is a free, open source CMS based on PHP. About 2.1% of the websites globally are powered by Drupal. Like other content management systems, it offers a wide range of modules that can be integrated into Drupal websites.
Slow Drupal website? KeyCDN can change that. Here’s why: KeyCDN will cache the static files of a Drupal website all around the world. In addition to optimizing a Drupal website, it’s essential to integrate a CDN for better performance. KeyCDN will cache the assets as long as specified in the HTTP headers defined by the origin server.
How does the Drupal CDN module work? The module will change the URL of static assets. The new URL will point to KeyCDN instead of the origin server. There is no redirection taking place, the URL will be rewritten to the KeyCDN domain. An example would be:
- URL to the origin server:
- New URL to KeyCDN:
Let’s get started with the Drupal CDN Integration
This tutorial shows how to complete a Drupal CDN integration with KeyCDN.
- Create a Pull Zone before you start with the Drupal CDN integration. A Push Zone would work as well but it’s not recommended here.
- Click on the menu item “Modules”, then click “Install New Module”.
- Go to Extend > Install new module > Install from a URL, enter the CDN Module URL:
http://ftp.drupal.org/files/projects/cdn-8.x-3.2.zip(check the official Drupal CDN module for the lastest version) and click “Install”.
- Go to the Extend page and under Web Services select both “CDN” and “CDN UI” then click Install.
- Navigate to Configure > Web Services > CDN Integration. Set the CDN status to enabled and enter your CDN URL that you get from the KeyCDN dashboard (e.g.
https://yourzone-ab12.kxcdn.com). You can also use your Zone Alias (e.g.
http://cdn.yoursite.com). Save the changes. The setting “Far Future expiration” will define higher caching values for the assets (valid for KeyCDN, as well as the client’s browser). Longer cached assets will result in less request to the CDN and the origin server, this can further improve the loading time. Alternatively, if you want to define higher caching values for assets, we recommend to do so in the KeyCDN dashboard for this specific Zone. Please note that content cached by KeyCDN can be purged anytime, but content cached by a browser cannot be purged.
- We always recommend checking the changes in the HTML code. Make sure the URLs have been rewritten properly.
That’s it. The Drupal CDN integration is completed. If there are any issues after the CDN integration, the KeyCDN support can be contacted anytime.
Drupal cache tags
Cache tag support was introduced with Drupal 8. Cache tags offer a convenient way to purge assets (also known as tag-based invalidation). It’s an alternative to purging by URL. The advantage of purging by tags is that several assets can have the same tag (vs. one asset can only have one URL).
The Drupal cache tags need to be added on the origin server. The
Cache-Tag is a regular HTTP header returned by the origin server. It’s possible to add several tags separated by spaces as shown in the example below. KeyCDN POPs preserve the tags, which means the tags are also visible to end clients.
Cache-Tag: tag1 tag2 tag3
Once the cache tags are in place, it’s very easy to purge them. Execute the following steps:
- Log in to the KeyCDN dashboard.
- In the left navigation sidebar click Zones.
- In the Zones table click the Zone menu that you want to purge. From the drop down click Purge by Tag.
- Enter one or more tags separated by a space (e.g.
tag1 tag2 tag3).
- Click Purge.
In addition to purging tags via the dashboard, it can be purge the same way through the API.
The benefits of using KeyCDN with Drupal
Once KeyCDN is integrated into a Drupal site, there are lots of advantages to benefit from:
- Access to our complete network of POPs. Content is always served from the closest location to the end users.
- Real-time statistics can be monitored in the KeyCDN dashboard.
- KeyCDN supports HTTP/2 for even faster content delivery. There’s no special configuration needed to take advantage of the new protocol.