Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1128
diff -u -p -r1.1128 common.inc
--- includes/common.inc	12 Mar 2010 14:20:32 -0000	1.1128
+++ includes/common.inc	13 Mar 2010 02:41:26 -0000
@@ -152,6 +152,34 @@ define('DRUPAL_CACHE_PER_PAGE', 0x0004);
 define('DRUPAL_CACHE_GLOBAL', 0x0008);
 
 /**
+ * Constants defining aggregation of JavaScript and CSS files.
+ */
+
+/**
+ * No aggregation.
+ */
+define('DRUPAL_AGGREGATION_DISABLED', 0);
+
+/**
+ * Default aggregation. The filename of the aggregate file is an md5 hash of
+ * the array of source file information. The last modified timestamp of each
+ * source file is part of this information, so when a source file is updated, it
+ * results in a new aggregate file being made.
+ */
+define('DRUPAL_AGGREGATION_ENABLED', 1);
+
+/**
+ * Optimized aggregation. The filename of the aggregate file is an md5 hash of
+ * the array of source file information. The last modified timestamp of each
+ * source file is not part of this information, so modification of source files
+ * does not automatically result in a new aggregate file. This saves on file
+ * stats, which can be significant for high traffic websites, but requires the
+ * site administrator to empty the aggregation cache whenever a source file is
+ * modified.
+ */
+define('DRUPAL_AGGREGATION_ENABLED_WITHOUT_STAT', 2);
+
+/**
  * Add content to a specified region.
  *
  * @param $region
@@ -2867,7 +2895,7 @@ function drupal_group_css($css) {
  * @see drupal_pre_render_styles()
  */
 function drupal_aggregate_css(&$css_groups) {
-  $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
+  $preprocess_css = (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') ? variable_get('preprocess_css', DRUPAL_AGGREGATION_ENABLED) : 0;
   $directory = file_directory_path('public');
   $is_writable = is_dir($directory) && is_writable($directory);
 
@@ -2878,6 +2906,19 @@ function drupal_aggregate_css(&$css_grou
       // the group's data property to the file path of the aggregate file.
       case 'file':
         if ($group['preprocess'] && $preprocess_css && $is_writable) {
+          // Unless aggregation is enabled without file stats, add each file's
+          // last modified timestamp to the information from which the aggregate
+          // filename will be generated.
+          if ($preprocess_css != DRUPAL_AGGREGATION_ENABLED_WITHOUT_STAT) {
+            foreach ($group['items'] as &$item) {
+              // Don't override information that may have been set earlier, such
+              // as in hook_css_alter().
+              if (!isset($item['mtime'])) {
+                $item['mtime'] = filemtime($item['data']);
+              }
+            }
+            unset($item);
+          }
           // Prefix filename to prevent blocking by firewalls which reject files
           // starting with "ad*".
           $filename = 'css_' . md5(serialize($group['items'])) . '.css';
@@ -3611,7 +3652,7 @@ function drupal_get_js($scope = 'header'
   $index = 1;
   $processed = array();
   $files = array();
-  $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
+  $preprocess_js = (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') ? variable_get('preprocess_js', DRUPAL_AGGREGATION_ENABLED) : 0;
   $directory = file_directory_path('public');
   $is_writable = is_dir($directory) && is_writable($directory);
 
@@ -3700,9 +3741,22 @@ function drupal_get_js($scope = 'header'
 
   // Aggregate any remaining JS files that haven't already been output.
   if ($is_writable && $preprocess_js && count($files) > 0) {
-    // Prefix filename to prevent blocking by firewalls which reject files
-    // starting with "ad*".
     foreach ($files as $key => $file_set) {
+      // Unless aggregation is enabled without file stats, add each file's
+      // last modified timestamp to the information from which the aggregate
+      // filename will be generated.
+      if ($preprocess_js != DRUPAL_AGGREGATION_ENABLED_WITHOUT_STAT) {
+        foreach ($file_set as &$item) {
+          // Don't override information that may have been set earlier, such
+          // as in hook_js_alter().
+          if (!isset($item['mtime'])) {
+            $item['mtime'] = filemtime($item['data']);
+          }
+        }
+        unset($item);
+      }
+      // Prefix filename to prevent blocking by firewalls which reject files
+      // starting with "ad*".
       $filename = 'js_' . md5(serialize($file_set)) . '.js';
       $preprocess_file = file_create_url(drupal_build_js_cache($file_set, $filename)) . '?' . $default_query_string;
       $js_element = $element;
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.262
diff -u -p -r1.262 system.admin.inc
--- modules/system/system.admin.inc	7 Mar 2010 07:36:27 -0000	1.262
+++ modules/system/system.admin.inc	13 Mar 2010 02:41:32 -0000
@@ -1668,15 +1668,25 @@ function system_performance_settings() {
     '#suffix' => '</div>',
   );
   $form['bandwidth_optimization']['preprocess_css'] = array(
-    '#type' => 'checkbox',
+    '#type' => 'radios',
     '#title' => t('Aggregate and compress CSS files into one file.'),
-    '#default_value' => intval(variable_get('preprocess_css', 0) && $is_writable),
+    '#options' => array(
+      DRUPAL_AGGREGATION_DISABLED => t('Disabled. This can be useful during development, but slows down page download and display.'),
+      DRUPAL_AGGREGATION_ENABLED => t('Normal (recommended)'),
+      DRUPAL_AGGREGATION_ENABLED_WITHOUT_STAT => t('Aggressive. This setting skips the normal verification of changes to source CSS files, potentially reducing disk load on high traffic website.'),
+    ),
+    '#default_value' => $is_writable ? variable_get('preprocess_css', DRUPAL_AGGREGATION_ENABLED) : 0,
     '#disabled' => $disabled,
   );
   $form['bandwidth_optimization']['preprocess_js'] = array(
-    '#type' => 'checkbox',
+    '#type' => 'radios',
     '#title' => t('Aggregate JavaScript files into one file.'),
-    '#default_value' => intval(variable_get('preprocess_js', 0) && $is_writable),
+    '#options' => array(
+      DRUPAL_AGGREGATION_DISABLED => t('Disabled. This can be useful during development, but slows down page download and display.'),
+      DRUPAL_AGGREGATION_ENABLED => t('Normal (recommended)'),
+      DRUPAL_AGGREGATION_ENABLED_WITHOUT_STAT => t('Aggressive. This setting skips the normal verification of changes to source JavaScript files, potentially reducing disk load on high traffic website.'),
+    ),
+    '#default_value' => $is_writable ? variable_get('preprocess_js', DRUPAL_AGGREGATION_ENABLED) : 0,
     '#disabled' => $disabled,
   );
 
