--- includes/bootstrap.inc.orig	2005-08-20 19:13:01.000000000 -0400
+++ includes/bootstrap.inc	2005-08-20 20:11:32.000000000 -0400
@@ -348,23 +348,23 @@
       db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
     }
     else {
-      $cache_flush = variable_get('cache_flush', 0);
-      // Loose caching, only flush temporary cache entries that have been
-      // invalidated for more than maximum allowable time.
-      if ($cache_flush && ($cache_flush + variable_get('cache_flush_delay', 300) <= time())) {
-        // Only flush cache data older than $cache_flush, as newer data may
-        // now be valid.
-        db_query("DELETE FROM {cache} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
-        variable_set('cache_flush', 0);
-      }
-      // Invalidate temporary cache data only for current user/session.  We
-      // set $user->cache, which gets saved into the sessions table by
-      // sess_write() in session.inc.
+      // We store the time in the current user's $user->cache variable which
+      // will be saved into the sessions table by sess_write.  We then simulate
+      // that the cache was flushed for this user by not returning cached data
+      // that was cached before the timestamp.
       $user->cache = time();
-      if (variable_get('cache_flush', 0) == 0) {
-        // Set timestamp to know which cache entries we eventually clear:
+
+      $cache_flush = variable_get('cache_flush', 0);
+      if ($cache_flush == 0) {
+        // This is the first request to clear the cache, start a timer.
         variable_set('cache_flush', time());
       }
+      else if (time() > ($cache_flush + variable_get('cache_flush_delay', 300))) {
+        // Clear the cache for everyone, cache_flush_delay seconds have
+	// passed since the first request to clear the cache.
+        db_query("DELETE FROM {cache} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
+        variable_set('cache_flush', 0);
+      }
     }
   }
   else {
@@ -879,4 +879,4 @@
   $theme = '';
 }
 
-?>
\ No newline at end of file
+?>
