Jojodae Ganesh Sivaji
April 1, 2013
If you are reading this blog post you must be striving to improve the performance of your site. When we speak about performance two things should be taken into account essentially.
I guess it is not much needed to stress how essential the response time plays in deciding the success of a website. Apache the prominent Web server plays a key role in this connection.
When configuring Apache for Drupal most of the tutorials recommend changing AllowOverride directive to All, including the official handbook page in drupal.org https://drupal.org/node/36628 , while the default is None.
This is needed to make .htaccess file in Drupal core to override the Apache config as needed. Especially to get a clean URL working. Besides it lets to set the page expiry time, and set necessary headers for css/js gzip compression if supported.
But this is a performance killer change!
Reason when AllowOverride is set to All. It prompts Apache to look for the existence of .htaccess file in recursive sub-folders as below.
/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess
and goes on...
Eventually, the number of I/O calls needed to serve the page request spikes up. Beware, I/O calls are expensive. And it goes further worst depending on the number of modules you have. Especially if you have hosted the site in VPS environments where disk operations are sub-optimal and can't be fully virtualized. The workaround for this problem is to tell Apache explicitly the location as to where to look for the overriding .htaccess file.
The following config helped us to fix the issue.
# Site example.com
<VirtualHost *:80>
ServerAdmin user@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Options -Indexes -FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Include /var/www/example.com/.htaccess
</Directory>
<Directory /var/www/example.com/sites/default/files>
Include /var/www/example.com/sites/default/files/.htaccess
</Directory>
</VirtualHost>
Additionally, apache's module mod_expires and mod_headers could be installed as Drupal's core .htaccess tries to leverage it if they exist.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!