Drush commands to enable/disable performance options in Drupal 7

Drush commands to enable/disable performance and cache related options in Drupal 7

The script presented in this post adds two new drush commands: cache-enable and cache-disable which gives us a handy way to disable / enable performance and cache related configuration parameters and options. These parameters can be found in the admin/config/development/performance section of a Drupal 7 installation.

The cache-enable actually performs all the following actions:
  1. Enables the "Cache pages for anonymous users" option
  2. Enables the "Cache blocks" option
  3. Sets the "Minimum cache lifetime" option to the required value. Defaults to 1 minute
  4. Sets the "Expiration of cached pages" option to the required value. Defaults to 1 hour 
  5. Enables the "Aggregate and compress CSS files" option
  6. Enables the "Aggregate JavaScript files" option 
  7. Finally clears all caches (same as pressing the "Clear All Caches" button)