Boost Drupal website speed

Looking for info on ways to enhance a Drupal website's speed, I found methods tended to be for hotshot developer types, perhaps in charge of their own dedicated servers. But there are methods, including using Drupal's own caching plus the Boost module, that work on shared hosting.

Though I have run Drupal sites for some time, and done a little to try and enhance their performance, I was prompted to search for more ways to boost speed after my web host recently stopped my sites (for only an hour) as they were causing a major slowdown with MySQL server, and I saw info on Google saying it's important that web pages load quickly.

You can find plenty of results when searching for info on accelerating Drupal sites - but often they are developer-oriented, with info for people in control of servers, such as on installing memcache, or php accelerators, and MySQL query caching. There are, though, some techniques that also apply to shared hosting.

It's worth trying at least some of these I think. A boon to visitors of course; also helps seach engine spiders to navigate site, and should mean less server resources used.

Minimise Page Sizes

This is a basic means of speeding loading of web pages. Pages should be as small as possible; not so much for text, which takes relatively little space, but page elements such as images should be as few and as small as possible. For jpeg files, say, can save them at less than highest quality: 6/10 in Photoshop gives results that still look good on screen to me.

There's a trade-off, of course, between having page look too bare, even if it loads instantly; and having one that looks great yet may take aeons to appear.

Use Fast Loading Templates

Not something I've looked at too much. But different Drupal templates load at different rates; I've seen at least one for which creator says it loads very quickly. As with regular page content, there is a balance needed, between page loading time, and how much the page itself appeals to visitors.

Minimise Modules

Loading Drupal modules can take time; so the fewer the better, timewise. Again, you surely need to strike a balance - especially as you're using Drupal for functionality provided by modules. But it's surely worth "turning off" and uninstalling modules you may have tried, but which don't prove worthwhile.

Use Drupal Caching (and Optimize css and Javascript)

Drupal has built-in caching (here, I'm using Drupal 6). You can access settings via Site configuration - Performance. Works for anonymous users.

The info here makes choosing settings pretty straightforward I think.

You might enable Normal caching, as well as block caching, and optimizing css and javascript files.

As for minimum cache time: I'm not too sure what it is that would normally trigger cached page info to be recreated, but perhaps something related to page views. The info suggests busy sites may need longer cache times; I don't know why a minimum of 0 secs (the default) should be ok for any site.

Advanced CSS/JS Aggregation

Rather than optimize css and javascript with Drupal core, use this suite of modules. As the intro text begins, "This is the holy grail of CSS & JS aggregation and optimization." I've just installed, editing this article to mention the modules; and does seem page loads are a lot faster.

Boost Module

The Boost module is the only strong option for extra speed on shared hosting.
[But a hassle to use with Mobile Tools, I think; after recommending it here, I've switched it off...]

As well as installing and configuring the module, maybe need to set website baseurl in settings.php file; and create cache folder, and folder for each of my sites of a multi-site install, making sure the site cache folders would be writable. Likewise, if choose to use gzip, should also create cache/gz/ folders, and make these writeable too.

This module works by creating static, html pages for each Drupal page for which this is possible. If such a page is available, the htaccess sends page request directly to it - so no need for Drupal queries and so forth, and page can load very fast; also way less demand on server inc MySQL database.
- note that as pages are cached on server, will increase memory usage; maybe need to watch in case this pushes the limit of memory you're allowed. To minimise memory usage, disallow batches of pages that don't need caching, such as:

(You could check the cached files, see where they may be some taking excess space.)

- also, as visits to cached pages bypass much of Drupal, there are issues with things like displaying Who's Online. These issues may be fixed at some stage (but maybe not, say, weather data). Plus, visits to cached pages won't trigger poormanscron.

Once installed, the module adds to Drupal's Performance page; as well as Boost settings, there's option for choosing gzip compression, which seems a good idea unless your server already performs such compression.
Various settings. Looks like it can cause issues with Captchas, which don't work on cached pages. One workaround for comments is to have comment forms on separate pages to main content, and disallow caching for them.

Enable the Boost static page cache, and it should start working. To check it's okay, visit your site as anonymous user, load and reload a page, and have a look at the source - if cached by Boost, should have a line at the bottom of the code saying so.

With boost, each cached page is given an expiry date: date/time it was created, plus "minimum time". This expiry date (time) is checked on cron runs. If a page time has passed when cron is run, the page cache is deleted; will be recreated when page next visited. Hence, if most of site doesn't change much, long cache times seem wise.

As caching of individual pages is triggered by anonymous visits to them, Boost includes a crawler, which roams through site after pages are cleared.

Blocks are included w this; one enables clearing cache for a certain page - such as front page at times when site updated, so you can ensure anonymous users see front page with new info, without need to delete caches sitewide.

Cacherouter Module

Another module for caching; this one lets users choose from a few caching methods, including database caching, and file caching. I figured database caching might swell and slow my MySQL server (on shared host), so leading to trouble w webhost and slower site. Tried file caching: it worked, but I had some trouble when wanted to add to a forum: I was logged out when viewing a list of forum threads. So, I uninstalled, switched to Boost; but Cacherouter remains a module to watch.


If you have other ideas, I'd be glad to learn them!

Need for Speed

For all Drupal can do impressive things, it can be fairly demanding for servers - plenty of request made in order to load even one page. Minimising such requests - inc by page caching - can thus speed pages, and reduce demands on servers: latter might be important in not upsetting webhosts!

Though broadband usage is increasing, recent Google info highlights need for speed; for instance - Speed Matters revealed results of tests, showing users could be deterred from making searches when results appeared even a little more slowly.

YSlow from Yahoo add-on for Firefox, and Google's Page Speed (Firebug plugin, also Firefox) can help check re speed, and give advice re making pages faster. Though various changes suggested are beyond me I'm afraid!

Martin Williams