Pixel Whip

What goes on in Production, stays in Production.

Using Drupal's settings.php file to turn off caching in your local development environment.

One of the first things we learn, when getting started with Drupal, is that the settings.php file is where our site's database settings live.   There is actually more to settings.php than just pointing Drupal to the correct database.

Settings.php can be used for all sorts of configuration.  Much of which I won't attempt to cover and is probably better left to your sys admin. However there are some settings that can be very helpful to any developer or themer.

Settings.php allows you to override any system variable in your variable database table. The syntax for this is pretty simple.

$conf['variable_name'] = value;

Below are a few variable configurations I find useful to add to my development environment's settings.php.

$conf['preprocess_js'] = 0;
$conf['preprocess_css'] = 0;
$conf['cache'] = 0;
$conf['block_cache'] = 0;
$conf['googleanalytics_account'] = "UA-XXXXXXX-X";

The first two turn off CSS and JS aggregation.  The next two turn off page and block caching. The last sets an invalid Google Analytics account number to prevent GA from tracking your local page views-- assuming you are using the Google Analytics module.

By setting variables in settings.php, you will always override variables set through the UI.  So, you no longer need to worry about turning off caching or aggregation when bringing in a new database dump from production.

It's important to note that each environment in which your site runs, should have its own settings.php.  This means, if you are using git for version control, you should always ignore you settings.php file.  This will prevent it from being deployed to different environments and keep your database settings hidden from those that may have access to your repository.