Blog/ Drupal Performance Optimization Checklist

By neerav.mehta Wed, 06/24/2015 - 10:45 10 Comments

You must have read plenty of articles on how to tweak your Drupal site to improve its page load times. This post assembles an exhaustive list of all the configuration changes you can do that help in Drupal performance tuning.


  1. Enable block cache. Blocks that don't change from one user to another can be cached and served.
  2. Enable Drupal cache for anonymous users. Use this if you are not using any other caching solution such as front-end cache (Varnish) or Boost.
  3. Cache views. There are plenty of options:Use this patch if you want to cache filtered results based on exposed filter selections as well.
    1. Time-based (built into core). Use this if you want to expire the Views cache after a specific period of time and if you are fine serving stale content for some period of time.
    2. Content cache. Use this if you want to expire the Views every time a content is inserted, updated or deleted. Use this if you expect content changes to happen rather infrequently on your site.
    3. Row cache. This caches the rendered output of each row separately but the query is not cached. Row results from the query are converted into a hash to store the rendered output of each row. If the row result changes, then the result is rendered again otherwise it is fetched from cache. Use this if you expect content changes to happen frequently on your site.
  4. Cache panels. There are plenty of options:
    1. Content cache. Use this if you want to expire the Panel cache whenever content is inserted, updated or deleted. Use this if you expect content changes to happen rather infrequently on your site.
    2. Page cache. Use this if you want to cache panel based on Drupal path and URL.
    3. Hash cache. Use this if you want panel to be cached with more granularity than just Drupal path and URL. This module allows you to create a custom hash for the cache based on contexts, arguments, Drupal path, URL, users and roles. Cache is expired automatically whenever any element of the hash changes.
  5. Cache rendered entities using Render cache module. You could also use Display cache module instead.
  6. Install distributed cache that can store cache tables of the database in memory or file. Drupal creates and uses its own cache. By default, it is stored in database in tables whose names start with "cache_". A distributed cache can instead store these caches in memory or file. The popular ones are:I prefer memcache since it's easy to install and configure. A lot of developers prefer Redis. I believe it's a tie between memcache and Redis. File Cache will be the slowest of the three so don't go with that.
    1. Memcache or Memcache Storage
    2. Redis
    3. File Cache
  7. Cache entities using Entity cache module. For warming up the entity cache, you can use Entity Cache Loader module.
  8. Enable Far Future Expiration for static assets. See the Webserver section of this article below for more details.
  9. Install a front-end cache. It stores the HTML response in memory. The next time, the same page is requested, it returns the HTML from memory. As a result, on the second request, web server and PHP are completely bypassed and the page load time is much faster. There are two good open-source front-end caches: Varnish and Squid. Drupal has much better support for Varnish such as expiring particular URLs using Rules. That's why I prefer Varnish.
  10. Use cache_get() and cache_set() functions in your custom modules to cache results from your custom functions.
  11. Use cache warmer to maintain fresh pages in cache. Use this for homepage and other Views pages that you don't want to clear on any content update.
  12. Use Content Delivery Networks (CDN). Cache static content (CSS, JS, fonts, files and images) using CDN such as AWS CloudfrontAkamaiFastly or Cloudflare. There are two advantages to using a CDN:
    1. Since CDNs have a different domain than your site, browsers load content from CDN in parallel to the requests to your domain. This speeds up page load even more.
    2. CDNs have endpoints throughout the world so the network delay is reduced.
  13. Use Asynchronous Prefetch Database Query Cache module for prefetching cache calls.


Contributed modules that improve performance

  1. Use Fast 404 module to return pages with 404 error without full Drupal bootstrap.
  2. Enable CSS/JS aggregation.
  3. Install and enable Advanced CSS/JS Aggregation module. Here is what you should do using this module:
    • Reduce the number of CSS/JS files even further than what Drupal core can do.
    • Gzip CSS/JS
    • Minify CSS/JS - You could use Speedy module instead.
    • Move JS to the bottom - Enable this feature with care. Your site may break if it needs some JS in the header. This can also be done by LABjs module.
  4. Create image sprites so that multiple background images can be served in the same request. Here are some ways to create sprites:
  5. Lazy load images so that only the images above the fold are requested initially. When user scrolls down, additional images are requested. There are multiple Drupal modules available:
  6. Laze load images in Views using Views Lazy Load module.
  7. Use Imageinfo Cache module to pre-generate image styles before they are requested for the first time. By default, Drupal generates image styles only on the first request. Using this module will ensure that the image style has already been created beofre the first request and even the first request is fast. In general, this module won't decrease your page load time much so use this only if you really really need 5 ms of reduction in page load time.
  8. Optimize images and reduce their size. There are multiple ways to do this:

    Convert non-transparent pngs to jpgs since jpgs are smaller.

  9. Disable logging using Performance module.
  10. Use Shadow module to create shadow tables for slow queries.
  11. Use Views Litepager module to eliminate COUNT queries from Views. InnoDB tables in MySQL do not store total count and hence a count query requires the engine to actually count the number of rows and that can slow down the query.
  12. Use Picture module for rendering responsive images. This ensures that on small screens, smaller images are downloaded which saves bandwidth and decreases page load time.



  1. Disable and uninstall modules that are not required for your application such as Update Manager and Statistics.
  2. On production, disable and uninstall modules that only provide UI functionality. Most common ones are Views UI and Rules UI.
  3. Disable Database log (dblog) module so that logs don't write to database. Enable syslog instead.
  4. Fix PHP code so that notices, warnings and errors are not generated and as a result, logging is minimized.
  5. Disable and uninstall modules that are active in the dabase but missing from the file system using Missing module.
  6. Use suggestions from Performance and Scalability Checklist module to improve performance.
  7. Rewrite your custom modules so that only the hooks are present in .module file. All the other functions should be in other files. Include these files as needed using module_load_include() and form_load_include() functions.
  8. Disable PHP Filter. It uses eval() function to run the code and that is slower than code that is compiled.
  9. Reduce the number of times that cron is run. By default, cron flushes Drupal's cache and as a result, frequent cron runs will trigger frequent cache flushes.


    Advanced methods

    1. Cache pages for authenticated users. Front-end caches generally cache pages for anonymous users. If your site is being used mostly by authenticated users, choose one of the following two options:

      1. Cache pages using front-end cache such as Varnish after removing all the cookies. All blocks that have user-specific or page-specific content are loaded using AJAX via AJAX Blocks module. The advantage of this approach is that webserver and PHP are not called when returning base HTML to the browser and as a result page load time decreases dramatically.
      2. Cache pages for authenticated users using Authcache. Use authcache if most blocks in your pages has user-specific or role-specific content. Although this is an excellent module and it works very well, it requires some configuration and maintenance. Also since it uses webserver and PHP, page times are slower than using a front-end cache such as Varnish.
    2. Speed up DNS requests. When you type a website URL in the browser, browser first contacts a DNS service to find the IP address. Typically this request takes anywhere from 50 ms to 200 ms. You can use DNS Anycast network to reduce this time. Some services that can help with this are: AWS Route 53easyDNSDNS Made EasyAkamaiDyn and Neustar UltraDNS.
    3. Use CDNs for serving dynamic content such as your complete HTML page. With this, you get the above two benefits even for your normal pages and not just for static assets. This requires a lot of configuration and we'll post another article on this soon.
    4. Inline critical CSS/JS. Browsers need to send multiple requests to the server before it can start rendering a page. Once it receives the HTML from the browser, it needs to request all the CSS and JS files present in the header. These are blocking requests and the page won't start rendering till they are received. By inlining the CSS/JS that you need to render the content that is above the fold, browsers don't need to make any more request to start rendering and hence the user perceives the page load times to be faster. This is a tool that is extremely useful for mobile devices since their bandwidth is generally limited and hence easy response takes a long time to arrive. There are multiple ways to do this:
      1. CSS Delivery module
      2. Pagespeed module for Apache and nginx. This can inline the critical CSS/JS on the fly and you don't need to change your site at all.
      3. Penthouse
      4. Critical



    1. Tune MySQL for better performance.
    2. Index slow queries.
    3. Optimize Views so that they use INNER JOIN instead of LEFT JOIN.
    4. Enable and configure MySQL query cache. It stores the results of past queries in memory. Next time the same query comes, it first sees if the results are already in memory. If yes, it returns the results from memory. If not, the query is passed to the MySQL query engine to fetch the results. MySQL query cache is always up-to-date, i.e. if any of the tables on which the query depends is modified, then the cache is cleared automatically. As a result, there is no need to clear MySQL query cache manually.
    5. Replace MySQL with Percona Server, a drop-in replacement that offers better performance
    6. Use MongoDB for storing key-value pairs.Using MongoDB does provide performance improvement of about 5% over MySQL. I prefer using Percona Server and then tuning it for better performance.



    There are plenty of open-source webservers. The two most frequent ones used with Drupal are Apache and Nginx. I have also seen IIS being used on Windows.

    1. Apache

    2. Nginx
    3. IIS

    I prefer using nginx since its event-driven model makes it much faster and more memory-efficient than Apache.



    1. Install PHP Opcode Cache. PHP is an interpreted language and it compiles during run-time. Compiler compiles it in two passes. In the first pass, PHP code is converted to an intermediate code (Opcode) which is platform-independent. In the next pass, this code gets converted to binary. Opcode caches store the intermediate code (Opode) in memory so that the next time code runs, compiler can fetch it from memory and skip the first pass. There are plenty of open-source Opcode caches available. Following are the popular ones. I prefer APC because it's easy to install and configure. Starting with PHP 5.5, PHP comes with Zend Optimizer by default so there won't be any need to install Opcode cache separately.

      1. APC

      2. eAccelerator
      3. XCache
      4. Zend Optimizer
    2. Use PHP-FPM. It is a high-performance FastCGI Process Manager.
    3. Compile PHP into binary. There are two options:
      1. HHVM
      2. Recki-CT

      If you are compiling PHP, make sure to test the application thoroughly before deploying it to production.



    Improve the performance of:

    1. Debian/Ubuntu
    2. Fedora/RHEL/CentOS
    3. Windows



    1. Replace disk drive by SSD (solid-state drives). I have seen a huge gain in performance using SSD.
    2. Increase RAM to make sure that swap never gets used.
    3. Increase CPU speed.


    If I have missed out on any technique, please let me know by writing a comment below and I'll prompty include it in this list.


    Related Articles:

    By Kenneth (not verified) Tuesday, July 21, 2015 - 01:18 Permalink

    Great info! Just would like to add this module to the list. I love JCH Optimize is great module for optimizing Drupal website speed. It's a one stop optimization module so it basically does almost all performance optimization reducing need of too many plugins.

    Thanks for your suggestion! It's still in sandbox with absolutely no information on its project page so it's impossible to say what it does. That said, I have cloned the module in my local machine and will check it out. If it works well, I'll include it in this list.

    By Matthew Matsuoka (not verified) Saturday, December 5, 2015 - 23:31 Permalink


    This is a great, and comprehensive article! I'd love to hear more about HTTP requests and how to minimize those.



    Matt, thanks for the feedback! To minimize HTTP requests, use Advanced CSS/JS aggregation module. For images, create image sprites.

    By Adam Williams (not verified) Wednesday, January 13, 2016 - 19:10 Permalink

    Brilliant article, this is going to save me a huge amount of time.

    I notice there are a large number of options relating to caching. Is it a case of implementing them all, or are they presented here to choose between?

    By NWOM (not verified) Monday, April 4, 2016 - 17:34 Permalink

    Thank you for the amazing guide. Many of these modules were new to me and thanks to your work, I am close to having an incredibly fast intranet portal. I recommend adding Panels Hash Cache ( to the list as well, since it is a great alternative to Authcache's Panels/Pane caching and has even more configurations available. Thanks again!

    By Azaz (not verified) Friday, April 29, 2016 - 20:27 Permalink

    Varnish is really great with Drupal as well. I have been using Varnish, Apache, Nginx and Memcached on my Drupal, because it is support by Cloudways, the managed hosting I am using. The first time I checked my benchmarks I was amazed. The response time was amazing compared to when I was using LAMP stack.

    By Simon via Iflexion (not verified) Saturday, August 27, 2016 - 02:19 Permalink

    Thanks! Well-done caching allows to speed up the site and get Google Page Speed Insight Score. We used this article optimizing even webdev company site It's working! 96% of Google score!

    Ready to get Started?