diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php
index 2dff1cd..ef7709e 100644
--- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php
@@ -84,7 +84,6 @@ public function testContactLink() {
 
     // Disable contact link for no_contact.
     $this->userData->set('contact', $no_contact_account->id(), 'enabled', FALSE);
-    Cache::invalidateTags($no_contact_account->getCacheTags());
     $this->drupalGet('test-contact-link');
     $this->assertContactLinks($accounts, array('root', 'admin'));
   }
diff --git a/core/modules/user/src/UserData.php b/core/modules/user/src/UserData.php
index 3f6b593..77ccc1d 100644
--- a/core/modules/user/src/UserData.php
+++ b/core/modules/user/src/UserData.php
@@ -7,7 +7,9 @@
 
 namespace Drupal\user;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Database\Connection;
+use Drupal\user\Entity\User;
 
 /**
  * Defines the user data service.
@@ -99,12 +101,16 @@ public function set($module, $uid, $name, $value) {
         'serialized' => $serialized,
       ))
       ->execute();
+
+    $this->invalidateUserCacheTags($uid);
   }
 
   /**
    * Implements \Drupal\user\UserDataInterface::delete().
    */
   public function delete($module = NULL, $uid = NULL, $name = NULL) {
+    // We do not need to invalidate cache tags here as this is invoked in
+    // User::postDelete().
     $query = $this->connection->delete('users_data');
     // Cast scalars to array so we can consistently use an IN condition.
     if (isset($module)) {
@@ -119,4 +125,25 @@ public function delete($module = NULL, $uid = NULL, $name = NULL) {
     $query->execute();
   }
 
+  /**
+   * Invalidate cache tags for the specified user.
+   *
+   * @param int $uids
+   *   The user account ID the data is associated with.
+   */
+  protected function invalidateUserCacheTags($uids) {
+    if (is_scalar($uids)) {
+      $uids = [$uids];
+    }
+    /** @var \Drupal\user\UserInterface[] $accounts */
+    $accounts = User::loadMultiple($uids);
+    if ($accounts) {
+      $tags = [];
+      foreach ($accounts as $account) {
+        $tags = Cache::mergeTags($tags, $account->getCacheTags());
+      }
+      Cache::invalidateTags($tags);
+    }
+  }
+
 }
