Tips to Speed Up Drupal Performance

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 and the search engines. Follow these tips below to speed up Drupal and keep it running fast to ensure return visitors:

Speed Up Drupal With Theses Steps:

  •  Latest Version
  • Content Delivery Network
  • Utilize Caching
  • Image Optimization
  • Lazy Load Images
  • 404s
  • Disable Unnecessary Modules
  • CSS/JS Aggregation
  • Reverse Proxy Server
  • Additional Tweaks
  • Choose Fast Web Hosting

1. Use 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.

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

Read other related Drupal tutorials:

A Basic Guide to Drupal Website Management

 Drupal Website Maintenance tutorial

 Drupal Website Security Tutorial

 Drupal configuration tutorial

2. Use a 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.

    Drupal CDN Integration

Now, lets look at the steps in Drupal CDN integration.

    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 Project Page 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 CDN dashboard,
    Save the changes.
    The setting “Far Future expiration” will define higher caching values for the assets. 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 CDN dashboard for this specific zone. Please note that content cached by CDN can be purged anytime, but content cached by a browser cannot be purged.
    A red warning box appears. Click on “Aggregate and compress CSS files”. Within the Bandwidth Optimization box, check Aggregate and compress CSS files and Aggregate JavaScript files, then save the configuration.
    We always recommend checking the changes in the HTML code. Make sure the URLs have been rewritten properly.

Read more Drupal tutorials:

Drupal's Paragraphs Module Tutorial

 How to Speed Up Your Drupal Website

 How to address "failed Drupal Clean url Test"

 How to optimize your Drupal website

 Installing a new Drupal website

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

    To enable, navigate to “Configuration” → “Development” → “Performance.”
    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.
    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.

    Memcache
    File Cache
    Redis
    Boost (turns all Drupal pages into flat HTML files)

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.

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

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

    Views Content Cache
    Cache Graceful
    Views Cache Bully

Panel Caching

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

        To enable, navigate to “Administration” → “Structure” → “Pages.”
        Then navigate to “Variants” → “Content” → “Caching” and click on “Change.”
        Select “Simple cache” and click “Next.”
        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 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..

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

    To change, navigate to “Configuration” → “Image toolkit.”
    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. Take Care of 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.

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

Note: This applies to both logged in and non-logged in 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.

    Varnish
    Cache Expiration

10. Additional Tweaks

    Add client side validation for web forms using jQuery with the “Clientside Validation” module.
    Choose a Drupal-specific web host.
    Disable database logging with the “Syslog-ng” module.
    Help figure out why your database is running slow with the DB Tuner module.
    Disable the PHP Filter module.

11. Choose Fast Web Hosting

And last but not least, choosing a reliable and fast web host like Todhost 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. 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, you can find a managed solution with Todhost..

About Drupal

Drupal is an open-source CMS and 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.

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 Drupal is preferred by web developers::

    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.

The  data, Drupal is widely more popular in the United States and western European countries.

Drupal by the numbers:

    38,000+ code contributors worldwide
    38% of the Fortune 50
    1M+ users on Drupal.org

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

Drupal and Speed Performance Improvement

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.

 

Conclusion

There are many ways you can speed up Drupal performance, you just have to know what to change alter or add. From implementing a CDN to caching, image optimization, lazy loading images, fixing 404s, aggregating CSS/JS Files, and disabling unnecessary modules, you can tremendously improve the performance of your Drupal website.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Speed Up Your Drupal Website

Drupal is one the top Content Management Systems used for web designing today. Like every other...

Installing a new Drupal website

This article takes you through how to install or set up a Drupal website on the internet.Step 1:...

Drupal configuration tutorial

To configure basic settings for your Drupal website, you first need to login to your Drupal...

Drupal Website Maintenance tutorial

Managing your Drupal website involves performing a lot of tasks which include securing your...

Drupal Website Security Tutorial

Drupal is increasingly gaining some popularity popularity and at the same time it is also...

Powered by WHMCompleteSolution