? boost-543840.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.90
diff -u -p -r1.3.2.2.2.5.2.90 boost.module
--- boost.module	6 Aug 2009 14:56:03 -0000	1.3.2.2.2.5.2.90
+++ boost.module	10 Aug 2009 00:06:58 -0000
@@ -771,24 +771,44 @@ function _boost_ob_handler($buffer) {
   }
 
 
-  // Check the currently set content type (at present we can't deal with
-  // anything else than HTML) and the HTTP response code. We're going to be
-  // exceedingly conservative here and only cache 'text/html' pages that
-  // were output with a 200 OK status. Anything more is simply asking for
-  // loads of trouble.
-  if ($GLOBALS['_boost_cache_this'] && _boost_get_http_status() == 200 && strlen($buffer) > 0) {
+  // Check the currently set content type and the HTTP response code. We're
+  // going to be exceedingly conservative here and only cache 'text' pages that
+  // were output with a 200 OK status. If it didn't get a 200 then remove that
+  // entry from the cache.
+  if ($GLOBALS['_boost_cache_this'] && strlen($buffer) > 0) {
     switch (_boost_get_content_type()) {
       case 'text/html':
-        boost_cache_set($GLOBALS['_boost_path'], $buffer);
-        boost_cache_css_js_files($buffer);
+        if (_boost_get_http_status() == 200) {
+          boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_FILE_EXTENSION);
+          boost_cache_css_js_files($buffer);
+        }
+        else {
+          $filename = boost_file_path($path, TRUE, BOOST_FILE_EXTENSION);
+          boost_cache_kill($filename);
+          boost_remove_db($filename);
+        }
         break;
       case 'application/rss':
       case 'text/xml':
       case 'application/rss+xml':
-        boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION);
+        if (_boost_get_http_status() == 200) {
+          boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION);
+        }
+        else {
+          $filename = boost_file_path($path, TRUE, BOOST_XML_EXTENSION);
+          boost_cache_kill($filename);
+          boost_remove_db($filename);
+        }
         break;
       case 'text/javascript':
-        boost_cache_set($GLOBALS['_boost_path'], $buffer, '.js');
+        if (_boost_get_http_status() == 200) {
+          boost_cache_set($GLOBALS['_boost_path'], $buffer, '.js');
+        }
+        else {
+          $filename = boost_file_path($path, TRUE, '.js');
+          boost_cache_kill($filename);
+          boost_remove_db($filename);
+        }
         break;
     }
   }
@@ -1235,6 +1255,16 @@ function boost_put_db($filename, $expire
 }
 
 /**
+ * Removes info from database. Use on 404 or 403.
+ *
+ * @param $filename
+ *   Name of cached file; primary key in database
+ */
+function boost_remove_db($filename) {
+  db_query("DELETE FROM {boost_cache} WHERE filename = '%s'", $filename);
+}
+
+/**
  * Puts boost info into database.
  *
  * @param $filename
