Index: .htaccess
===================================================================
RCS file: /cvs/drupal/drupal/.htaccess,v
retrieving revision 1.103
diff -u -u -p -r1.103 .htaccess
--- .htaccess	21 Jun 2009 10:48:06 -0000	1.103
+++ .htaccess	21 Jun 2009 14:28:16 -0000
@@ -7,6 +7,16 @@
   Order allow,deny
 </FilesMatch>
 
+# Gzip compressed css files are of the type 'text/css'.
+<FilesMatch "\.css\.gz$">
+  ForceType text/css
+</FilesMatch>
+
+# Gzip compressed js files are of the type 'text/javascript'.
+<FilesMatch "\.js\.gz$">
+  ForceType text/javascript
+</FilesMatch>
+
 # Don't show directory listings for URLs which map to a directory.
 Options -Indexes
 
@@ -54,6 +64,12 @@ DirectoryIndex index.php index.html inde
   </Files>
 </IfModule>
 
+# Requires mod_mime to be enabled.
+<IfModule mod_mime.c>
+  # Send any files ending in .gz with x-gzip encoding in the header.
+  AddEncoding x-gzip .gz
+</IfModule>
+
 # Various rewrite rules.
 <IfModule mod_rewrite.c>
   RewriteEngine on
@@ -89,6 +105,16 @@ DirectoryIndex index.php index.html inde
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
+
+  # Serve gzip compressed css files
+  RewriteCond %{HTTP:Accept-encoding} gzip
+  RewriteCond %{REQUEST_FILENAME}\.gz -s
+  RewriteRule (.*)\.css$ $1\.css\.gz [L,QSA,T=text/css]
+
+  # Serve gzip compressed js files
+  RewriteCond %{HTTP:Accept-encoding} gzip
+  RewriteCond %{REQUEST_FILENAME}\.gz -s
+  RewriteRule (.*)\.js$ $1\.js\.gz [L,QSA,T=text/javascript]
 </IfModule>
 
 # $Id: .htaccess,v 1.103 2009/06/21 10:48:06 dries Exp $
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.925
diff -u -u -p -r1.925 common.inc
--- includes/common.inc	18 Jun 2009 21:19:01 -0000	1.925
+++ includes/common.inc	21 Jun 2009 14:28:16 -0000
@@ -2530,6 +2530,9 @@ function drupal_build_css_cache($types, 
 
     // Create the CSS file.
     file_unmanaged_save_data($data, $csspath . '/' . $filename, FILE_EXISTS_REPLACE);
+    if (variable_get('page_compression', TRUE) && function_exists('gzencode') && zlib_get_coding_type() == FALSE) {
+      file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $csspath . '/' . $filename . '.gz', FILE_EXISTS_REPLACE);
+    }
   }
   return $csspath . '/' . $filename;
 }
@@ -3112,6 +3115,9 @@ function drupal_build_js_cache($files, $
 
     // Create the JS file.
     file_unmanaged_save_data($contents, $jspath . '/' . $filename, FILE_EXISTS_REPLACE);
+    if (variable_get('page_compression', TRUE) && function_exists('gzencode') && zlib_get_coding_type() == FALSE) {
+      file_unmanaged_save_data(gzencode($contents, 9, FORCE_GZIP), $jspath . '/' . $filename . '.gz', FILE_EXISTS_REPLACE);
+    }
   }
 
   return $jspath . '/' . $filename;
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.158
diff -u -u -p -r1.158 system.admin.inc
--- modules/system/system.admin.inc	19 Jun 2009 20:35:05 -0000	1.158
+++ modules/system/system.admin.inc	21 Jun 2009 14:28:16 -0000
@@ -1335,7 +1335,7 @@ function system_performance_settings() {
     '#title' => t('Page compression'),
     '#default_value' => variable_get('page_compression', TRUE),
     '#options' => array(t('Disabled'), t('Enabled')),
-    '#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression."),
+    '#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. If CSS and/or JS aggregation is enabled, the aggregated files will also be compressed and served to compatible browsers. This option should be disabled when using a webserver that performs compression."),
   );
 
   $form['bandwidth_optimizations'] = array(
