Other Web Server Optimizations

There are a few other things that you can do to make your web server run more efficiently.

Apache Optimizations

Apache is the most common web server used with Drupal, and it can be tweaked to provide better performance. The following sections will suggest some approaches to try.

mod_expires

This Apache module will let Drupal send out Expires HTTP headers, caching all static files in the user's browser for two weeks or until a newer version of a file exists. This goes for all images, CSS and JavaScript files, and other static files. The end result is reduced bandwidth and less traffic for the web server to negotiate. Drupal is preconfigured to work with mod_expires and will use it if it is available. The settings for mod_expires are found in Drupal's . htaccess file.

# Requires mod_expires to be enabled. <IfModule mod_expires.c>

# Enable expirations. ExpiresActive On

# Cache all files for 2 weeks after access (A). ExpiresDefault A1209600

# Do not cache dynamically generated pages. ExpiresByType text/html A1

</IfModule>

We can't let mod_expires cache HTML content, because the HTML content Drupal outputs is not always static. This is the reason Drupal has its own internal caching system for its HTML output (i.e., page caching).

Moving .htaccess Files

Drupal ships with two .htaccess files: one is at the Drupal root, and the other is automatically generated after you create your directory to store uploaded files and visit Administer >■ File system to tell Drupal where the directory is. Any .htaccess files are searched for, read, and parsed on every request. In contrast, httpd.conf is only read when Apache is started. Apache directives can live in either file. If you have control of your own server, you should move the contents of the .htaccess files to the main Apache configuration file (httpd.conf) and disable .htaccess lookups within your web server root by setting AllowOverride to None:

<Directory /> AllowOverride None

</Directory>

This prevents Apache from traversing up the directory tree of every request looking for the .htaccess file to execute. Apache will then have to do less work for each request, giving it more time to serve more requests.

Other Web Servers

Another option is to use a web server other than Apache. Benchmarks have shown that, for example, the LightTPD web server generally serves more requests per second for Drupal. See http://buytaert.net/drupal-webserver-configurations-compared for more detailed comparisons.

Was this article helpful?

0 0

Post a comment