diff -Naur modules/block/block.module modules/block/block.module
--- modules/block/block.module	2007-09-12 03:49:35.000000000 -0400
+++ modules/block/block.module	2007-11-05 10:35:46.102287647 -0500
@@ -286,6 +286,7 @@
   }
   drupal_set_message(t('The block settings have been updated.'));
   cache_clear_all();
+  cache_clear_all('*', 'cache_advcache_block', TRUE);
 }
 
 /**
@@ -500,6 +501,7 @@
     module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values);
     drupal_set_message(t('The block configuration has been saved.'));
     cache_clear_all();
+    cache_clear_all('*', 'cache_advcache_block', TRUE);
     return 'admin/build/block';
   }
 }
@@ -538,6 +540,7 @@
   db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
   drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
   cache_clear_all();
+  cache_clear_all('*', 'cache_advcache_block', TRUE);
   return 'admin/build/block';
 };
 
@@ -643,26 +646,39 @@
   static $blocks = array();
 
   if (!count($blocks)) {
-    $rids = array_keys($user->roles);
-    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
-    $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", array_merge(array($theme_key), $rids));
-    while ($block = db_fetch_object($result)) {
-      if (!isset($blocks[$block->region])) {
-        $blocks[$block->region] = array();
-      }
-      // Use the user's block visibility setting, if necessary
-      if ($block->custom != 0) {
-        if ($user->uid && isset($user->block[$block->module][$block->delta])) {
-          $enabled = $user->block[$block->module][$block->delta];
+    $cache_key = $user->uid. '::'. $theme_key;
+    $cache = cache_get($cache_key, 'cache_advcache_block');
+    $enabled_blocks = unserialize($cache->data);
+    if (empty($enabled_blocks)) {
+      $enabled_blocks = array();
+      $rids = array_keys($user->roles);
+      $placeholders = implode(',', array_fill(0, count($rids), '%d'));
+      $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", array_merge(array($theme_key), $rids));
+      while ($block = db_fetch_object($result)) {
+        if (!isset($blocks[$block->region])) {
+          $blocks[$block->region] = array();
+        }
+        // Use the user's block visibility setting, if necessary
+        if ($block->custom != 0) {
+          if ($user->uid && isset($user->block[$block->module][$block->delta])) {
+            $enabled = $user->block[$block->module][$block->delta];
+          }
+          else {
+            $enabled = ($block->custom == 1);
+          }
+
         }
         else {
-          $enabled = ($block->custom == 1);
+          $enabled = TRUE;
+        }
+        if ($enabled) {
+          $enabled_blocks[] = $block;
         }
       }
-      else {
-        $enabled = TRUE;
-      }
+      cache_set($cache_key, 'cache_advcache_block', serialize($enabled_blocks));
+    }
 
+    foreach ($enabled_blocks as $block) {
       // Match path if necessary
       if ($block->pages) {
         if ($block->visibility < 2) {
@@ -686,7 +702,7 @@
         $page_match = TRUE;
       }
 
-      if ($enabled && $page_match) {
+      if ($page_match) {
         // Check the current throttle status and see if block should be displayed
         // based on server load.
         if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
