11 Tips to Speed up Drupal Performance

By Brian Jackson
Updated on December 30, 2022
11 Tips to Speed up Drupal Performance

Drupal is an open source CMS and or framework that is used by at least 1.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.
  • 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:

  • Pfizer
  • Nestlé
  • Nokia
  • NASA
  • Habitat for Humanity
  • DHL
  • And Many More!

According to W3Techs, Drupal currently holds a 1.8% market share, making it one of the most popular CMSs. Only Joomla, Squarespace, Wix, Shopify and WordPress are still ahead. According to BuiltWith, 4% of the top 100,000 websites use Drupal.

Source: BuiltWith

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

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.

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 400 ms 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 100 ms 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.

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.

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.

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."

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)."
  5. Select the time you desire and click on "Apply (all displays)."

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."
  3. Select "Simple cache" and click "Next."
  4. You can then select your caching time duration and click on "Save."

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 style sheets 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;

Expires headers

Expires 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('/\.css\?[^"]+/','.css', $variables['styles']);
}

?>

Fortunately, if you are using KeyCDN, this is not needed. 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."

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.

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. 404 errors

Instead of using a module to check for 404 errors, 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-100 MB 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 1 MB 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"

This will be applied to both logged in and logged out users.

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 DigitalOcean or Linode. 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 404 errors, 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.

  • Share

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started

Comments

Comment policy: Comments are welcomed and encouraged. However, all comments are manually moderated and those deemed to be spam or solely promotional in nature will be deleted.
  • **bold**
  • `code`
  • ```block```
KeyCDN uses cookies to make its website easier to use. Learn more