Quick and simple ways to speed up a Drupal site

Attaining performance and scalability in a large Drupal site requires a good amount of time and effort. In addition, speed gains become smaller and smaller after more and more work is spent. Eventually, the exercise becomes futile.

On the other end of this optimization, you can do a few things to a small Drupal site from nothing at all and considerably decrease load times; also, (almost) no coding is required.

Here are a handful suggestions that will help almost any Drupal site and they are easy to do.

Integrate Memcached, a memory based caching tool.

  • Good:
    • Faster than Drupal’s DB based caching.
    • Two modules available: Memcache and Cache Router.
    • No more patching for Drupal 6.
  • Bad:
    • Patching required for Drupal 5.
  • Notes:
    • Need to have Memcached installed and running.
    • Either module will work, cache router is more flexible in that it can use caching tools other than Memcached.
    • In a multi-web server setup, configure Memcache settings (in settings.php) to use IP address instead of 'localhost', so that the web servers may share Memcached bin(s) and increase cache hit rate.
    • Click here for a reference on applying patches.

Use Path Cache module to cache URL aliases.

  • Good:
    • Reduces URL lookup queries (drupal_lookup_path) considerably.
  • Bad:
    • Useless without Memcached integration; actually, this module will make things worse by increasing DB queries for cache_get and cache_set calls.
    • Requires patching.
    • Module only available for Drupal 6.
  • Notes:
    • I rewrote the patch to work with Drupal 5.16 and it works well; download the patch here; as the for the module file itself, it is not really needed as the key parts are in the patch.

Use Boost module to cache whole pages to files.

  • Good:
    • Serving the cached pages is blazing fast – no hit to the Drupal stack or DB.
    • Choose to cache certain pages or exclude specific ones.
  • Bad:
    • Only for anonymous (non-logged in) users.
    • Doesn’t work on a Windows server?
  • Notes:
    • It is important to modify .htaccess as directed and the cache directory
      in the root of the Drupal directory has to be writable.
    • Set a minimum cache lifetime; 30 minutes a good number to start with.
    • When the page doesn’t look right upon reload, try excluding the path.

Use Javascript Aggregator to “compress” JS files.

  • Good:
    • Provides Drupal 6 JS aggregation to Drupal 5.
    • Minifies JS files.
  • Bad:
    • Some JS code may not work properly after being minified.
  • Notes:
    • Clear cache or delete crated JS file every time JS code has been updated.

Move JS to bottom of page.

  • Good:
    • Page becomes visible even JS component is not yet fully loaded.
  • Bad:
    • You will get JS errors if you have inline JS code because of dependency issues with JQuery or other libraries.
  • Notes:
    • Cut and paste <?php print $scripts ?> from the top of the page.tpl.php template file to the bottom before the closing 'body' tag.

Gzip components on the fly to decrease page size.

  • Good:
    • Page download time and bandwidth usage goes down.
  • Notes:
    • Add the following to your .htaccess:
       AddOutputFilterByType DEFLATE text/plain
       AddOutputFilterByType DEFLATE text/xml
       AddOutputFilterByType DEFLATE application/xhtml+xml
       AddOutputFilterByType DEFLATE text/css
       AddOutputFilterByType DEFLATE application/xml
       AddOutputFilterByType DEFLATE image/svg+xml
       AddOutputFilterByType DEFLATE application/rss+xml
       AddOutputFilterByType DEFLATE application/atom_xml
       AddOutputFilterByType DEFLATE application/x-javascript
       AddOutputFilterByType DEFLATE application/x-httpd-php
       AddOutputFilterByType DEFLATE application/x-httpd-fastphp
       AddOutputFilterByType DEFLATE application/x-httpd-eruby
       AddOutputFilterByType DEFLATE text/html
      
    • Requires the Apache module, mod_deflate.
AttachmentSize
cachepath.patch4.29 KB
Thanks

Great summary post about the multi-faceted world of website/server optimization.

Submitted by Anonymous on Apr 30, 2009 - 1:16am.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Prove you're not a bad bot.
4 + 16 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Tag Cloud

Syndicate content

Powered by Pressflow, an open source content management system