diff --git includes/bootstrap.inc includes/bootstrap.inc
index 80f10b1..3f48e05 100644
--- includes/bootstrap.inc
+++ includes/bootstrap.inc
@@ -2056,7 +2056,7 @@ function _drupal_bootstrap_page_cache() {
     $cache = drupal_page_get_cache();
     // If there is a cached page, display it.
     if (is_object($cache)) {
-      header('X-Drupal-Cache: HIT');
+       drupal_add_http_header('X-Drupal-Cache', 'HIT');
       // Restore the metadata cached with the page.
       $_GET['q'] = $cache->data['path'];
       drupal_set_title($cache->data['title'], PASS_THROUGH);
@@ -2076,7 +2076,20 @@ function _drupal_bootstrap_page_cache() {
       exit;
     }
     else {
-      header('X-Drupal-Cache: MISS');
+      // Cache miss. Avoid a stampede.
+      require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
+      lock_initialize();
+      $name = '_drupal_bootstrap_page_cache';
+      if (!lock_acquire($name, 1)) {
+        // Some other request is building cache. Wait, then re-run this function.
+         drupal_add_http_header('X-Drupal-Cache', 'WAIT');
+        lock_wait($name);
+        return _drupal_bootstrap_page_cache();
+      }
+      else {
+        // Proceed with page build;  cache its result, then release the lock.
+        drupal_add_http_header('X-Drupal-Cache', 'MISS');
+      }
     }
   }
 }
diff --git includes/common.inc includes/common.inc
index 788d2a5..1711573 100644
--- includes/common.inc
+++ includes/common.inc
@@ -4544,6 +4544,7 @@ function drupal_page_set_cache() {
         $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
       }
       cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire);
+      lock_release('_drupal_bootstrap_page_cache');
     }
     return $cache;
   }
@@ -5187,7 +5188,7 @@ function drupal_render_cache_get($elements) {
   }
   $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
 
-  if (!empty($cid) && $cache = cache_get($cid, $bin)) {
+  if ($cache = cache_get($cid, $bin)) {
     // Add additional libraries, JavaScript, CSS and other data attached
     // to this element.
     if (isset($cache->data['#attached'])) {
@@ -5196,7 +5197,18 @@ function drupal_render_cache_get($elements) {
     // Return the rendered output.
     return $cache->data['#markup'];
   }
-  return FALSE;
+  else {
+    // Cache miss. Avoid a stampede.
+    if (!lock_acquire($cid, 1)) {
+      // Some other request is building cache. Wait, then re-run this function.
+      lock_wait($cid);
+      return drupal_render_cache_get($elements);
+    }
+    else {
+      // Proceed with rendering, cache the result, and then release the lock.
+      return FALSE;
+    }
+  }
 }
 
 /**
@@ -5232,6 +5244,7 @@ function drupal_render_cache_set(&$markup, $elements) {
   $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
   $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT;
   cache_set($cid, $data, $bin, $expire);
+  lock_release($cid);
 }
 
 /**
