Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.308
diff -u -p -r1.308 bootstrap.inc
--- includes/bootstrap.inc	3 Oct 2009 19:27:44 -0000	1.308
+++ includes/bootstrap.inc	6 Oct 2009 04:43:10 -0000
@@ -985,6 +985,7 @@ function drupal_page_header() {
     'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
     'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
     'ETag' => '"' . REQUEST_TIME . '"',
+    'Connection' => 'close',
   );
   drupal_send_headers($default_headers);
 }
@@ -1045,6 +1046,10 @@ function drupal_serve_page_from_cache(st
       && $if_modified_since == $cache->created) {  // if-modified-since must match
     header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
     drupal_send_headers($default_headers);
+    flush();
+    syslog(LOG_NOTICE, 'Running cron after sending a 304 header to the browser.');
+    include_once DRUPAL_ROOT . '/includes/common.inc';
+    drupal_cron_run();
     return;
   }
 
@@ -1086,7 +1091,15 @@ function drupal_serve_page_from_cache(st
     }
   }
 
+  ob_start();
   print $cache->data;
+  drupal_add_http_header('Connection', 'close');
+  drupal_add_http_header('Content-Length', strlen($cache->data));
+  ob_end_flush();
+  flush();
+  syslog(LOG_NOTICE, 'Running cron after serving a page from the database cache.');
+  include_once DRUPAL_ROOT . '/includes/common.inc';
+  drupal_cron_run();
 }
 
 /**
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1008
diff -u -p -r1.1008 common.inc
--- includes/common.inc	5 Oct 2009 02:48:38 -0000	1.1008
+++ includes/common.inc	6 Oct 2009 04:43:10 -0000
@@ -2587,12 +2587,17 @@ function drupal_page_footer() {
     drupal_serve_page_from_cache($cache);
   }
   else {
-    ob_flush();
+    drupal_add_http_header('Content-Length', ob_get_length());
+    ob_end_flush();
+    flush();
   }
-
+  
+  // We have closed the browser connection. Perform any slow bookkeeping that's needed.
   _registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
   drupal_cache_system_paths();
   module_implements_write_cache();
+  syslog(LOG_NOTICE, 'Running cron at the end of a normal page request.');
+  drupal_cron_run();
 }
 
 /**
@@ -4110,6 +4115,11 @@ function drupal_cron_run() {
     variable_set('cron_last', REQUEST_TIME);
     watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
 
+    for ($i = 1; $i <= 10; $i++) {
+      sleep(1);
+      syslog(LOG_NOTICE, "Running cron for $i seconds.");
+    }
+
     // Release cron semaphore
     variable_del('cron_semaphore');
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.801
diff -u -p -r1.801 system.module
--- modules/system/system.module	5 Oct 2009 02:43:01 -0000	1.801
+++ modules/system/system.module	6 Oct 2009 04:43:10 -0000
@@ -2415,6 +2415,10 @@ function system_cron() {
   $core = array('cache', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
   $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
   foreach ($cache_tables as $table) {
+    if ($table == 'cache_page') {
+      // To aid in testing cron runs on cached pages.
+      continue;
+    }
     cache_clear_all(NULL, $table);
   }
 
