diff --git a/includes/common.inc b/includes/common.inc
index b6ea297..823e2a4 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -7287,6 +7287,7 @@ function entity_get_info($entity_type = NULL) {
           'fieldable' => FALSE,
           'controller class' => 'DrupalDefaultEntityController',
           'static cache' => TRUE,
+          'static cache max size' => 100,
           'field cache' => TRUE,
           'load hook' => $name . '_load',
           'bundles' => array(),
diff --git a/includes/entity.inc b/includes/entity.inc
index a3cdf74..a7ddc4a 100644
--- a/includes/entity.inc
+++ b/includes/entity.inc
@@ -57,7 +57,7 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
    *
    * @var array
    */
-  protected $entityCache;
+  public $entityCache;
 
   /**
    * Entity type for this controller instance.
@@ -204,13 +204,6 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
       $entities += $queried_entities;
     }
 
-    if ($this->cache) {
-      // Add entities to the cache if we are not loading a revision.
-      if (!empty($queried_entities) && !$revision_id) {
-        $this->cacheSet($queried_entities);
-      }
-    }
-
     // Ensure that the returned array is ordered the same as the original
     // $ids array if this was passed in and remove any invalid ids.
     if ($passed_ids) {
@@ -221,6 +214,13 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
       }
       $entities = $passed_ids;
     }
+    if ($this->cache) {
+      // Add entities to the cache if we are not loading a revision. We need to
+      // cacheSet entities in the cache as well for LRU.
+      if (!$revision_id) {
+        $this->cacheSet($entities);
+      }
+    }
 
     return $entities;
   }
@@ -373,13 +373,22 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
   }
 
   /**
-   * Stores entities in the static entity cache.
+   * Stores entities in the static entity cache. Least recently used (LRU) are
+   * purged in order to honor 'static cache max size' property. Use
+   * hook_entity_info_alter() to change this property.
    *
    * @param $entities
    *   Entities to store in the cache.
    */
   protected function cacheSet($entities) {
-    $this->entityCache += $entities;
+    // Prepend these items.
+    $this->entityCache = $entities + $this->entityCache;
+
+    // Check if the cache is greater than the max cache size and purge
+    // the nodes at the bottom of the array as they are the least recently used.
+    if (count($this->entityCache) > $this->entityInfo['static cache max size']) {
+      $this->entityCache = array_slice($this->entityCache, 0, $this->entityInfo['static cache max size'], TRUE);
+    }
   }
 }
 
diff --git a/modules/node/node.test b/modules/node/node.test
index 8a871c0..4c7c250 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -2146,3 +2146,71 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
     }
   }
 }
+
+/**
+ * Test restriction of the number of nodes to be held in the static cache.
+ */
+class NodeLoadRestrictionTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Node restriction',
+      'description' => "Check cache size restriction of node_load() to only retain no more than 'static cache max size'.",
+      'group' => 'Node',
+    );
+  }
+
+  function testNodeRestrictions() {
+    $info = entity_get_info('node');
+    for ($i = 0; $i < $info['static cache max size'] + 10; $i++) {
+      $node = $this->drupalCreateNode(array('type' => 'article'));
+      $node_keys[] = $node->nid;
+    }
+
+    $node_cache = &drupal_static('node_load_multiple', array(), TRUE);
+
+    // Attempt to overfill the node cache.
+    foreach ($node_keys as $nid) {
+      node_load($nid);
+    }
+
+    // Check if the cache has too many nodes in it.
+    $this->assertTrue(count($node_cache) <= $info['static cache max size'], t('The static node cache is less than or equal to the Maximum cache size'));
+  }
+}
+
+/**
+ * Test restriction of the number of nodes to make sure the most recent is at
+ * the beginning of the node cache and less likey to be removed.
+ */
+class NodeLoadPurgeOrderTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Node restriction purge order',
+      'description' => 'Check cache size restriction of node_load() is moving the most recently loaded nodes to the beginning.',
+      'group' => 'Node',
+    );
+  }
+
+  function testNodeRestrictionsPurgeOrder() {
+    $info = entity_get_info('node');
+    for ($i = 0; $i < $info['static cache max size'] + 10; $i++) {
+      $node = $this->drupalCreateNode(array('type' => 'article'));
+      $node_keys[] = $node->nid;
+    }
+
+    $popular_nid = array_shift($node_keys);
+
+    $controller = entity_get_controller('node');
+    $controller->resetCache();
+
+    // Fill the node cache.
+    foreach ($node_keys as $nid) {
+      node_load($nid);
+      node_load($popular_nid);
+    }
+
+    $popular_node = reset($controller->entityCache);
+    // Check if the cache has the right node on top.
+    $this->assertEqual($popular_node->nid, $popular_nid, t('The node at the top of the cache is the popular node'));
+  }
+}
