Index: boost.module
===================================================================
--- boost.module	(revision 197)
+++ boost.module	(working copy)
@@ -300,7 +300,7 @@
   chdir(dirname($_SERVER['SCRIPT_FILENAME']));
 
   // Check the currently set content type; at present we can't deal with anything else than HTML.
-  if (_boost_get_content_type() == 'text/html') {
+  if (_boost_get_content_type() == 'text/html' && _boost_get_http_status() == 200) {
     if (strlen($buffer) > 0) { // Sanity check
       boost_cache_set($GLOBALS['_boost_path'], $buffer);
     }
@@ -318,14 +318,27 @@
  * has overridden the content type.
  */
 function _boost_get_content_type($default = NULL) {
-  static $regex = '/^Content-Type:\s*([\w\d\/\-]+)/i';
+  static $regex = '!^Content-Type:\s*([\w\d\/\-]+)!i';
+  return _boost_get_http_header($regex, $default);
+}
 
-  // The last Content-Type header is the one that counts:
+/**
+ * Determines the HTTP response code that the current page request will be
+ * returning by examining the HTTP headers that have been output so far.
+ */
+function _boost_get_http_status($default = 200) {
+  static $regex = '!^HTTP/1.1\s+(\d+)!';
+  return (int)_boost_get_http_header($regex, $default);
+}
+
+function _boost_get_http_header($regex, $default = NULL) {
+  // The last header is the one that counts:
   $headers = preg_grep($regex, explode("\n", drupal_set_header()));
-  if (!empty($headers) && preg_match($regex, array_pop($headers), $matches))
+  if (!empty($headers) && preg_match($regex, array_pop($headers), $matches)) {
     return $matches[1]; // found it
-
-  return $default;
+  }
+  return $default; // no such luck
 }
 
+
 //////////////////////////////////////////////////////////////////////////////
