11 Tips to Speed Up Drupal Performance

speed up drupal performance

Drupal is an open-source CMS and or framework that is used by at least 2.2% of all the websites on the internet. It powers all types of websites ranging from blogs to corporate and government sites. In this post, we will discuss tips on how to speed up Drupal performance to ensure your website keeps running fast, ensuring a good experience for your visitors.

Drupal was originally released in 2001, two years before WordPress was even on the market. With WordPress being so popular, many people ask why someone would choose Drupal over WordPress? Here are a few reasons:

  • Security: Drupal has enterprise-level security and provides in-depth security reports. WordPress tends to have more plugins with vulnerabilities, especially if the owner doesn’t update them.
  • Scaling: Drupal was meant to scale to thousands of pages! WordPress was originally designed as blogging platform and actually runs into a memory issues after 100 pages.
  • Powerful: Drupal was designed with developers in mind and so the design possibilities are endless, especially with its modular design.

“We chose to go with a Drupal-based platform because it is open source, has a dynamic developer community, and offers a powerful and flexible platform for building online communities.” Mitch Kapor, Electronic Frontier Foundation

Drupal is currently used on many popular sites such as:

  • Warner Brothers Records
  • Amherst College
  • Digett
  • Popular Science
  • Symantec Connect
  • Examiner
  • The Economist
  • The White House
  • And Many More!

According to W3Techs, Drupal currently holds a 5% market share, putting it as the third most popular CMS, with only Joomla and WordPress ahead of it. According to BuiltWith, 9% of the top 100,000 websites are using Drupal.

drupal market share

CMS Market share Src: BuiltWith

And according to the regional data, Drupal is widely more popular in the United States and western European countries.

drupal regional data

Drupal Regional Market share Src: BuiltWith

Drupal by the numbers:

According to Google Trends the activity around Drupal is pretty consistent, maybe showing a slight decline over the past couple years. However, it is interesting to see the large decline with Joomla, which we can probably assume that this is mainly due to WordPress.

google trends drupal

Speed Up Drupal Performance

Why should you care about speeding up Drupal? Because the speed of your website greatly affects your traffic, conversions, revenue, and even SEO rankings! Here are stats from a case study Radware did on page load times.

  • Shopzilla saw a 12% revenue increase after improving average page load times from 6 seconds to 1.2 seconds.
  • Google says they lose 20% of their traffic for each additional 100 milliseconds it takes a page to load. Speed matters. Google also incorporates your page-load time into your site’s search rankings.
  • Yahoo increased traffic by 9% for every 400ms of improvement.
  • Mozilla got 60 million more Firefox downloads per year, by making their pages 2.2 seconds faster.
  • Amazon increased revenue by 1% for every 100ms of improvement.

Follow these tips below on how to speed up Drupal and keep it running fast to ensure return visitors. We are using Drupal 7.41. Please note that Drupal 8 is being released on November 19th. A few changes include dropping core support for IE 6,7, & 8 and adding support for PHP7.

Speed Up Drupal Index

  1. Latest Version
  2. Content Delivery Network
  3. Utilize Caching
  4. Image Optimization
  5. Lazy Load Images
  6. 404s
  7. Disable Unnecessary Modules
  8. CSS/JS Aggregation
  9. Reverse Proxy Server
  10. Additional Tweaks
  11. Choose Fast Web Hosting

1. Latest Version

It is very important that you are always running the latest version of Drupal as updates generally contain bug fixes and performance improvements. You always want to keep the core, contribs module, and themes updated.

  1. To run updates, navigate to “Reports” → “Available Updates.”
  2. You can then click on “Check manually” to scan for additional updates.

drupal updates

2. Content Delivery Network

Implementing a Content Delivery Network (CDN) with Drupal is a fast and easy way to instantly see decreased load times for your website. By doing this, you will ensure you are serving your assets (product images, javascript, CSS) from multiple locations around the globe so they are delivered faster to your visitors and reducing latency.

CDN

KeyCDN has a simple 8 step integration with Drupal in which you can follow.

3. Utilize Caching

Drupal, unlike many other CMS platforms actually has some caching options built into the core. This is probably the easiest way to speed up Drupal performance on your site. By default this is turned off.

Page Caching

  1. To enable, navigate to “Configuration” → “Development” → “Performance.”
  2. Enable “Cache pages for anonymous users” and also “Cache blocks.” You can then choose a time value for minimum cache lifetime and expiration of cached pages.
  3. Click on “Save configuration.”

drupal caching

If you are wondering about the different between minimum cache lifetime and expiration of cached pages there is a pretty good explanation here.

However just like any other CMS, the bundled caching options usually aren’t as efficient. Here are some other caching options to also look at.

Here is a full list of caching modules that make Drupal scale.

Views Caching

The views module is probably one of the most popular modules on Drupal. If you have it installed you can also enable caching on it.

    1. To enable, navigate to “Administration” → “Structure” → “Views.”
    2. Click “Edit” on the view you want to enable caching on.
    3. Expand the “Advanced box.”
    4. Select “Time-based” and click on “Apply (all displays).”

drupal views caching

  1. Select the time you desire and click on “Apply (all displays).”

drupal views caching

Here are some other modules that you can also use for caching views:

Panel Caching

Another popular module people normally use is in Drupal is the panels module. You can actually enable caching on each individual panel.

    1. To enable, navigate to “Administration” → “Structure” → “Pages.”
    2. Then navigate to “Variants” → “Content” → “Caching” and click on “Change.”

drupal panels caching

    1. Select “Simple cache” and click “Next.”

drupal panels caching

  1. You can then select your caching time duration and click on “Save.”

drupal panels caching

PHP Caching

Alternative PHP Cache (APC) has been very well known to help increase the speed of Drupal installs.

Browser Caching

Another form of caching you can leverage is browser caching. See the following snippets you can add to your server, such as enabling Gzip compression and adding expire headers.

Gzip Compression

Gzip compresses web pages and stylesheets at the server level before sending them over to the browser. If you are running on Apache you can enable compression by adding the following to your .htaccess file.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

If you are running on Nginx You can enable compression by adding the following to your nginx.conf file.

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;

Expire Headers

Expire headers tell the browser whether they should request a file from the server or grab it from the browser’s cache.

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>

Remove Query Strings from Static Resources

It can also be beneficial to remove query strings from your static resources as this can cause caching issues with some proxy caches and CDNs. To remove query strings from CSS filenames within Drupal, the following code snippet can be added to your template.php file. Just remember to modify MYTHEME with your theme name.

<?php 

/**
* Implements template_process_html().
*/

 Remove Query Strings from CSS filenames (CacheBuster)
 function MYTHEME_process_html(&$variables) {
 $variables['styles'] = preg_replace('https://blog.keycdn.com/blog/\.css\?[^"]+/','.css', $variables['styles']);
 }
 
?>

Fortunately, if you are using KeyCDN, this is not needed as we have a featured called “Ignore Query String” that you can enable within the dashboard. This feature ignores query strings and tells the cache to reply with a cached reply even if the query string differs.

Read our more in-depth post on removing query strings.

4. Image Optimization

We talked about lossless image compression in a previous post, on average 56 percent of a website’s page weight is made up of images. So optimizing images can drastically decrease your page load times and is something we always recommend doing when it comes to Drupal performance.

In Drupal 6 and 7 you can change the compression ratio on JPEGs. By default in Drupal 7 it is set  to 75%.

  1. To change, navigate to “Configuration” → “Image toolkit.”
  2. You can then change the % amount and click on “Save configuration.”

drupal image optimization

There are also Drupal image optimization modules available such as Image Optimize and ImageMagick.

5. Lazy Load Images

Lazy loading images can an easy to dramatically increase your page load times by ensuring the image will only load when it is visible to the browser window. The most popular Drupal module for this is currently the “Image Lazyloader” with a little over 18,000 downloads.

drupal lazy load images

We also recommend using a module like “Image Resize Filter” so that your images are scaled down when you upload them and you aren’t relying on CSS to scale them down.

6. 404s

Instead of using a module to check for 404s, we recommend occasionally running your website through an external service such as the “Online Broken Link Checker” or a tool like Screaming Frog. This ensures that you aren’t wasting any of your server’s resources on this task.

Also Drupal has expensive 404 errors. On an ‘average’ site with an ‘average’ module load, you can be looking at 60-100MB of memory being consumed on your server to deliver a 404. The Drupal Fast 404 module fixes this and usually can deliver 404 errors using less than 1MB of memory.

7. Disable Unnecessary Modules

Just like with any CMS platform and plugins, each module in Drupal has overhead attached. So it is recommended not to run more than 50 modules. Here are some modules you can disable if you don’t need the functionality for your site.

  • Administration Development tools
  • Devel
  • Devel node access
  • Field UI
  • Rules UI
  • Views UI
  • Module Filter
  • Blog
  • Forum
  • Taxonomy
  • Search
  • Help
  • Shortcut
  • Dashboard
  • Database Logging
  • Color
  • Toolbar
  • Tracker
  • Statistics  (this module writes to your database on every page load. If you are using Google Analytics you probably don’t need this.)
  • Update Manager (if you have a dev to prod migration environment there is no reason you need the update manager polling drupal.org all the time.)

8. CSS/JS Aggregation

By aggregating your CSS and Javascript files you can improve your frontend performance and download times, as your browser doesn’t have to fetch as many files and it reduces the total number of HTTP requests being made.

  1. To enable, navigate to “Configuration” → “Development” → “Performance.”
  2. Enable “Aggregate and compress CSS files” and “Aggregate Javascript files.”
  3. Click on “Save configuration.”

Note: This applies to both logged in and non-logged in users.

speed up drupal css javascript aggregate

For more advanced CSS and Javascript aggregation we recommend checking out the “Advanced CSS/JS Aggregation” module.

9. Reverse Proxy Server

It’s possible to place another application in front of yours that will serve cached copies of your Web pages. This is called “reverse proxy caching” or sometimes also known as an “HTTP accelerator”. Varnish is used for high-traffic websites like Wikipedia, Facebook, Twitter, etc. There are two popular Drupal modules when it comes to using Varnish.

10. Additional Tweaks

11. Choose Fast Web Hosting

And last but not least, choosing a reliable and fast web host can be one of the most important decisions you will make when trying to improve Drupal performance. We recommend staying away from cheap shared hosting as they tend to overcrowd their servers and you will end up sharing resources between hundreds of people. We suggest going with a VPS like Digital OceanLinode, or Vultr. The reason is because you will be in complete control of your resources. And if you aren’t as tech savvy or don’t want to manage your servers via CLI, ServerPilot is a great control panel alternative which works with Drupal and the VPS providers mentioned above.

Summary

As you can see there are many ways you can speed up Drupal performance, you just have to know where to look. From implementing a CDN to caching, image optimization, lazy loading images, fixing 404s, aggregating CSS/JS Files, and disabling unnecessary modules.

Do you have another way to speed up Drupal that we missed? We would love to hear about it below in the comments.

Related Articles

11 Tips to Speed Up Drupal Performance was last modified: June 29th, 2016 by Brian Jackson
Share This