? boost-546850.patch
Index: boost.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v
retrieving revision 1.1.2.1.2.3.2.61
diff -u -p -r1.1.2.1.2.3.2.61 boost.admin.inc
--- boost.admin.inc	29 Aug 2009 10:19:55 -0000	1.1.2.1.2.3.2.61
+++ boost.admin.inc	29 Aug 2009 23:48:01 -0000
@@ -383,6 +383,12 @@ function boost_admin_boost_performance_p
     '#default_value' => BOOST_DISABLE_CLEAN_URL,
     '#description'   => t('Drupal will output non clean url\'s for non anonymous users. This allows for the browser to cache the page and still have logging in work. This is more on the extreme side of tweaks.'),
   );
+  $form['advanced']['boost_aggressive_gzip'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Do an iframe javascript cookie test for gzip'),
+    '#default_value' => BOOST_AGGRESSIVE_GZIP,
+    '#description'   => t('Inject an iframe on the homepage on the non-gzip version to check if the browser can actually handle gzip encoding. See <a href="@url">Website Performance - Activate Gzip</a> for reason why.', array('@url' => 'http://actionable-stats.com/website-performance-activate-gzip')),
+  );
   $form['advanced']['boost_permissions_file'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Files: Enter in a 4 digit number (octal) that will be used by !link. Example 0664', array('!link' => l(t('chmod()'), 'http://php.net/chmod'))),
@@ -651,7 +657,7 @@ function boost_admin_generate_htaccess($
   $_gz = BOOST_GZIP_EXTENSION;
 
   $char = BOOST_CHAR;
-  $permanant_char = BOOST_PERM_CHAR;
+  $permanent_char = BOOST_PERM_CHAR;
 
   $string = <<<ETO
   ### BOOST START ###
@@ -685,19 +691,23 @@ function boost_admin_generate_htaccess($
     ForceType text/javascript
   </FilesMatch>
 
+  # Gzip Cookie Test
+  RewriteRule boost-gzip-cookie-test\.html  $cache_dir$permanent_dir_gzip/boost-gzip-cookie-test\.html\.gz [L,T=text/html]
+
   # GZIP - Cached css & js files
+  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
   RewriteCond %{HTTP:Accept-encoding} !gzip
   RewriteRule .* - [S=2]
-  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanant_char$css$gz -s
-  RewriteRule .* $cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanant_char$css$gz [L,QSA,T=text/css]
-  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanant_char$js$gz -s
-  RewriteRule .* $cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanant_char$js$gz [L,QSA,T=text/javascript]
+  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanent_char$css$gz -s
+  RewriteRule .* $cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanent_char$css$gz [L,QSA,T=text/css]
+  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanent_char$js$gz -s
+  RewriteRule .* $cache_dir$permanent_dir_gzip/$server_name%{REQUEST_URI}$permanent_char$js$gz [L,QSA,T=text/javascript]
 
   # NORMAL - Cached css & js files
-  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanant_char$css -s
-  RewriteRule .* $cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanant_char$css [L,QSA,T=text/css]
-  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanant_char$js -s
-  RewriteRule .* $cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanant_char$js [L,QSA,T=text/javascript]
+  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanent_char$css -s
+  RewriteRule .* $cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanent_char$css [L,QSA,T=text/css]
+  RewriteCond $document_root$drupal_subdir/$cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanent_char$js -s
+  RewriteRule .* $cache_dir$permanent_dir/$server_name%{REQUEST_URI}$permanent_char$js [L,QSA,T=text/javascript]
 
   # Caching for anonymous users
   # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request
@@ -708,6 +718,7 @@ function boost_admin_generate_htaccess($
   RewriteRule .* - [S=7]
 
   # GZIP
+  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
   RewriteCond %{HTTP:Accept-encoding} !gzip
   RewriteRule .* - [S=3]
   RewriteCond $document_root$drupal_subdir/$cache_dir$gzip_dir/$server_name%{REQUEST_URI}$char%{QUERY_STRING}$html$gz -s
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.113
diff -u -p -r1.3.2.2.2.5.2.113 boost.module
--- boost.module	29 Aug 2009 10:19:55 -0000	1.3.2.2.2.5.2.113
+++ boost.module	29 Aug 2009 23:48:02 -0000
@@ -49,6 +49,7 @@ define('BOOST_POST_UPDATE_COMMAND',  var
 define('BOOST_CRON_LIMIT',           variable_get('boost_cron_limit', 100));
 define('BOOST_ONLY_ASCII_PATH',      variable_get('boost_only_ascii_path', TRUE));
 define('BOOST_GZIP',                 variable_get('page_compression', TRUE));
+define('BOOST_AGGRESSIVE_GZIP',      variable_get('boost_aggressive_gzip', TRUE));
 define('BOOST_CLEAR_CACHE_OFFLINE',  variable_get('boost_clear_cache_offline', TRUE));
 define('BOOST_HALT_ON_ERRORS',       variable_get('boost_halt_on_errors', FALSE));
 define('BOOST_ROOT_FILE',            variable_get('boost_root_file', '.boost'));
@@ -1244,7 +1245,14 @@ function boost_cache_set($path, $data = 
 
   // Create or update the static files as needed
   if (($filename = boost_file_path($path, TRUE, $extension)) && (BOOST_OVERWRITE_FILE || !file_exists($filename) || boost_db_is_expired($filename))) {
-    boost_cache_write($filename, $data);
+    // Special handling of the front page for aggressive gzip test
+    if ($path == '' && BOOST_AGGRESSIVE_GZIP) {
+      _boost_generate_gzip_test();
+      boost_cache_write($filename, _boost_gzip_test_inject_iframe($data));
+    }
+    else {
+      boost_cache_write($filename, $data);
+    }
     if (BOOST_GZIP) {
       boost_cache_write(str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename) . BOOST_GZIP_EXTENSION, gzencode($data, 9));
     }
@@ -2112,6 +2120,38 @@ function _boost_variable_set($name, $val
   db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", serialize($value), $name);
 }
 
+/**
+ * Generate iframe gzip cookie test html.
+ */
+function _boost_generate_gzip_test() {
+  $filename = BOOST_ROOT_CACHE_DIR . '/' . BOOST_PERM_GZ_DIR . '/boost-gzip-cookie-test.html.gz';
+  if (!file_exists($filename)) {
+    $string = <<<ETO
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+  "http://www.w3.org/TR/html4/loose.dtd">
+<html><head><title>Gzip Test</title>
+<script type="text/javascript">
+var date = new Date();
+var days = 14;
+date.setTime(date.getTime() + (days * 24*60*60*1000));
+expires = '; expires=' + date.toUTCString();
+document.cookie = 'boost-gzip=true' + expires + '; path=/'
+</script>
+</head><body><h1>It works!</h1></body></html>
+ETO;
+    _boost_mkdir_p(dirname($filename));
+    file_put_contents($filename, gzencode($string, 9));
+  }
+
+}
+
+/**
+ * Inject iframe gzip cookie test.
+ */
+function _boost_gzip_test_inject_iframe($data) {
+ return str_replace('</body>', '<iframe src="/boost-gzip-cookie-test.html" style="width:0px; height:0px; border: 0px"></iframe>' . "\n" . '</body>', $data);
+}
+
 //////////////////////////////////////////////////////////////////////////////
 // PHP 4.x compatibility
 
