Technologies: Drupal 5+, PHP (optional), MySQL (optional), Apache (optional)
An initial installation of the Drupal content management system can be slow. You can speed up your web site substantially by making a few essential adjustments to your site's web server, database, PHP, and Drupal configurations. This article introduces a series of articles on the steps to take and why.
Configure the web server
Drupal is a popular content management system written using PHP and typically installed using a MySQL database and an Apache web server. If you have administrator authority over the computer running Apache, PHP, and MySQL, making a few adjustments can halve page load times and substantially speed up your web site. If the computer serves multiple web sites, all of them will benefit.
The default configurations for Apache, PHP, and MySQL have important performance features turned off. The following articles in this series provide step-by-step instructions and explanations to turn these features on:
- Speed up a Drupal web site by enabling PHP accelerator script caching. The Drupal content management system is a program written in the PHP script language. A PHP engine converts Drupal into an executable program every time a web page is needed. This takes time, slowing down the site. Install and enable a PHP script cache to save and re-use converted scripts, speeding up the site.
- Speed up a Drupal web site by enabling MySQL query caching. Drupal often uses a MySQL database to store site content, such as blog entries, forum posts, comments, user information, and so forth. Every database query takes time. Enable MySQL's query cache to save and re-use the results of common queries, speeding up the site.
Drupal has several built-in performance features that can further reduce page load times and speed up your site. The default configuration for Drupal has these features turned off. The following series articles show how to turn them on:
- Speed up a Drupal web site by enabling Drupal page caching. Drupal builds and rebuilds web pages for every site visitor. This takes time. Speed up a site by enabling Drupal's page cache to save and re-use pre-built web pages.
- Speed up a Drupal web site by enabling CSS file aggregation. A Drupal theme and many of it's modules have CSS files to style content. The more files there are, the longer it takes to send them to a site visitor. Speed up a site by enabling Drupal's CSS file aggregation to combine these files together into one large file, and to remove extra white-space and comments.
- Speed up a Drupal web site by enabling block caching. Each block you add to a site design adds functionality, but it also adds time to query the block's data from a database or the Internet and format it for the page. Some blocks take longer than others, slowing down your web site. Speed up some types of slow blocks by replacing them with cached versions that are quicker to assemble into your site's pages.
Configure your theme and page layout
Drupal makes it easy to enable lots of features and decorate your site with all sorts of blocks listing recent content, current users, the latest weather report, and lots more. Drupal's theming system lets you download and install hundreds of different themes, or author your own to create a very fancy look and feel. But beware. The more you add to your site, the slower it goes.
The following articles in this series include step-by-step instructions, explanations, and benchmarks showing the costs for blocks and theming choices and what you can do about them:
- Speed up a Drupal web site by avoiding slow blocks in your page layout. Every block you add to your site's page layout increases the time Drupal uses to assemble each page. Many blocks also add style sheets, images, and scripts to your pages. While enabling a block cache can help, you can speed up the site further by simply not using as many blocks.
However, it's easy to get carried away fiddling with everything to extract the maximum performance from a site. Sometimes, the effort is just not worth the savings:
- Don't bother using HTML white-space removal to speed up a web site. HTML web pages often include spaces, tabs, blank lines, and comments hidden within the page. Removing them makes the page smaller without changing the page's appearance. The smaller file is faster to send to a site visitor but the number of bytes saved is tiny and the performance gain negligible.
- Don't bother using CSS optimization to speed up a web site. CSS files often include spaces, blank lines, comments, and redundant selectors and properties. Removing them makes the CSS smaller and faster to send to a site visitor. But the improvement is won't yield a noticeable improvement in page load times.