diff --git a/core/modules/views/lib/Drupal/views/ViewsDataCache.php b/core/modules/views/lib/Drupal/views/ViewsDataCache.php
index 15e338c..94e3fd4 100644
--- a/core/modules/views/lib/Drupal/views/ViewsDataCache.php
+++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.php
@@ -31,6 +31,13 @@ class ViewsDataCache implements DestructableInterface {
   protected $cacheBackend;
 
   /**
+   * The configuration factory object.
+   *
+   * @var \Drupal\Core\Config\ConfigFactory
+   */
+  protected $config;
+
+  /**
    * Storage for the data itself.
    *
    * @var array
@@ -38,39 +45,39 @@ class ViewsDataCache implements DestructableInterface {
   protected $storage = array();
 
   /**
-   * The configuration factory object.
+   * An array of requested tables.
    *
-   * @var \Drupal\Core\Config\ConfigFactory
+   * @var array
    */
-  protected $config;
+  protected $requestedTables = array();
 
   /**
-   * The current language code.
+   * Whether the data has been fully loaded in this request.
    *
-   * @var string
+   * @var bool
    */
-  protected $langcode;
+  protected $fullyLoaded = FALSE;
 
   /**
-   * Whether the data has been fully loaded in this request.
+   * Whether views data has been rebuilt. This is set when getData() doesn't return anything from cache.
    *
    * @var bool
    */
-  protected $fullyLoaded = FALSE;
+  protected $rebuildAll = FALSE;
 
   /**
    * Whether or not to skip data caching and rebuild data each time.
    *
    * @var bool
    */
-  protected $skipCache;
+  protected $skipCache = FALSE;
 
   /**
-   * Whether the cache should be rebuilt. This is set when getData() is called.
+   * The current language code.
    *
-   * @var bool
+   * @var string
    */
-  protected $rebuildCache;
+  protected $langcode;
 
   public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $config) {
     $this->config = $config;
@@ -81,44 +88,48 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactory
   }
 
   /**
-   * Gets cached data for a particular key, or rebuilds if necessary.
+   * Gets data for a particular table, or all tables.
    *
    * @param string|null $key
-   *   The key of the cache entry to retrieve. Defaults to NULL.
+   *   The key of the cache entry to retrieve. Defaults to NULL, this will
+   *   return all table data.
    *
    * @return array $data
-   *   The cached data.
+   *   An array of table data.
    */
   public function get($key = NULL) {
     if ($key) {
       if (!isset($this->storage[$key])) {
+        // Prepare a cache ID.
         $cid = $this->baseCid . ':' . $key;
-        $data = $this->cacheGet($cid);
-        if (!empty($data->data)) {
+
+        if ($data = $this->cacheGet($cid)) {
           $this->storage[$key] = $data->data;
+          $from_cache = TRUE;
         }
         else {
           // No cache entry, rebuild.
           $this->storage = $this->getData();
-          $this->fullyLoaded = TRUE;
+          $from_cache = FALSE;
         }
       }
+
       if (isset($this->storage[$key])) {
+        if (!$from_cache) {
+          // Add this table to a list of requested tables, as it's table cache
+          // entry was not found.
+          array_push($this->requestedTables, $key);
+        }
+
         return $this->storage[$key];
       }
+
       // If the key is invalid, return an empty array.
       return array();
     }
     else {
       if (!$this->fullyLoaded) {
-        $data = $this->cacheGet($this->baseCid);
-        if (!empty($data->data)) {
-          $this->storage = $data->data;
-        }
-        else {
-          $this->storage = $this->getData();
-        }
-        $this->fullyLoaded = TRUE;
+        $this->storage = $this->getData();
       }
     }
 
@@ -128,19 +139,17 @@ public function get($key = NULL) {
   /**
    * Sets the data in the cache backend for a cache key.
    *
-   * @param string $key
-   *   The cache key to set.
+   * @param string $cid
+   *   The cache ID to set. The language code will be appended to the key.
    * @param mixed $value
    *   The value to set for this key.
    */
-  public function set($key, $value) {
+  protected function set($cid, $value) {
     if ($this->skipCache) {
       return FALSE;
     }
 
-    $key .= ':' . $this->langcode;
-
-    $this->cacheBackend->set($key, $value);
+    $this->cacheBackend->set($this->prepareCid($key), $value);
   }
 
   /**
@@ -158,26 +167,47 @@ protected function cacheGet($cid) {
       return FALSE;
     }
 
-    $cid .= ':' . $this->langcode;
+    return $this->cacheBackend->get($this->prepareCid($cid));
+  }
 
-    return $this->cacheBackend->get($cid);
+  /**
+   * Prepares the cache ID by appending a language code.
+   *
+   * @param string $cid
+   *   The cache ID to prepare.
+   *
+   * @return string
+   *   The prepared cache ID.
+   */
+  protected function prepareCid($cid) {
+    return $cid .= ':' . $this->langcode;
   }
 
   /**
    * Gets all data invoked by hook_views_data().
    *
+   * This is requested from the cache before being rebuilt.
+   *
    * @return array
    *   An array of all data.
    */
   protected function getData() {
-    $data = module_invoke_all('views_data');
-    drupal_alter('views_data', $data);
+    $this->fullyLoaded = TRUE;
 
-    $this->processEntityTypes($data);
+    if ($data = $this->cacheGet($this->baseCid)) {
+      return $data->data;
+    }
+    else {
+      $data = module_invoke_all('views_data');
+      drupal_alter('views_data', $data);
+
+      $this->processEntityTypes($data);
 
-    $this->rebuildCache = TRUE;
+      // Set as TRUE, so all table data will be cached.
+      $this->rebuildAll = TRUE;
 
-    return $data;
+      return $data;
+    }
   }
 
   /**
@@ -245,13 +275,16 @@ public function fetchBaseTables() {
    * Implements \Drupal\Core\DestructableInterface::destruct().
    */
   public function destruct() {
-    if ($this->rebuildCache && !empty($this->storage)) {
-      // Keep a record with all data.
-      $this->set($this->baseCid, $this->storage);
-      // Save data in seperate cache entries.
-      foreach ($this->storage as $table => $data) {
+    if (!empty($this->storage)) {
+      if ($this->rebuildAll) {
+        // Keep a record with all data.
+        $this->set($this->baseCid, $this->storage);
+      }
+
+      // Save data in seperate, per table cache entries.
+      foreach ($this->requestedTables as $table) {
         $cid = $this->baseCid . ':' . $table;
-        $this->set($cid, $data);
+        $this->set($cid, $this->storage[$table]);
       }
     }
   }
