diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 2bb65077621dc41dd60653ae4a3906b318809f2a..70d74a1ef5ee6fc3d7659586060573e0a72b3e34 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -9,19 +9,20 @@
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\DrupalKernel;
 use Symfony\Component\HttpFoundation\Request;
-use Composer\Autoload\ClassLoader;
 
 /**
  * Rebuilds all caches even when Drupal itself does not work.
  *
- * @param \Composer\Autoload\ClassLoader $class_loader
- *   The class loader.
+ * @param $class_loader
+ *   The class loader. Normally Composer's ClassLoader, as included by the
+ *   front controller, but may also be decorated; e.g.,
+ *   \Symfony\Component\ClassLoader\ApcClassLoader, \Symfony\Component\ClassLoader\WinCacheClassLoader, or \Symfony\Component\ClassLoader\XcacheClassLoader
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @see rebuild.php
  */
-function drupal_rebuild(ClassLoader $class_loader, Request $request) {
+function drupal_rebuild($class_loader, Request $request) {
   // Remove Drupal's error and exception handlers; they rely on a working
   // service container and other subsystems and will only cause a fatal error
   // that hides the actual error.
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index ba2c0fbd23738e9cf17476535550dd291cbf0334..274a3fa71e6353564f17972127b957e1f8313879 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -23,6 +23,8 @@
 use Drupal\Core\Test\TestDatabase;
 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\ClassLoader\ApcClassLoader;
+use Symfony\Component\ClassLoader\WinCacheClassLoader;
+use Symfony\Component\ClassLoader\XcacheClassLoader;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -1028,16 +1030,29 @@ protected function initializeSettings(Request $request) {
       }
     }
 
-    // If the class loader is still the same, possibly upgrade to the APC class
-    // loader.
+    // If the class loader is still the same, possibly
+    // upgrade to an optimized class loader.
     if ($class_loader_class == get_class($this->classLoader)
-        && Settings::get('class_loader_auto_detect', TRUE)
-        && function_exists('apcu_fetch')) {
+        && Settings::get('class_loader_auto_detect', TRUE)) {
       $prefix = Settings::getApcuPrefix('class_loader', $this->root);
-      $apc_loader = new ApcClassLoader($prefix, $this->classLoader);
-      $this->classLoader->unregister();
-      $apc_loader->register();
-      $this->classLoader = $apc_loader;
+      $loader = NULL;
+
+      // We autodetect one of the following three optimized classloaders, if
+      // their underlying extension exists.
+      if (function_exists('apcu_fetch')) {
+        $loader = new ApcClassLoader($prefix, $this->classLoader);
+      }
+      elseif (extension_loaded('wincache')) {
+        $loader = new WinCacheClassLoader($prefix, $this->classLoader);
+      }
+      elseif (extension_loaded('xcache')) {
+        $loader = new XcacheClassLoader($prefix, $this->classLoader);
+      }
+      if (!empty($loader)) {
+        $this->classLoader->unregister();
+        $loader->register();
+        $this->classLoader = $loader;
+      }
     }
   }
 
diff --git a/core/rebuild.php b/core/rebuild.php
index 4e69eabf655faba696bea70ab9c754624e143dc0..fc432d7d59fb718b3f6daff9b133dcf045b2d6e9 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -42,10 +42,14 @@
     ((REQUEST_TIME - $request->query->get('timestamp')) < 300) &&
     Crypt::hashEquals(Crypt::hmacBase64($request->query->get('timestamp'), Settings::get('hash_salt')), $request->query->get('token'))
   )) {
-  // Clear the APCu cache to ensure APCu class loader is reset.
-  if (function_exists('apcu_clear_cache')) {
-    apcu_clear_cache();
-  }
+  // Clear user cache for all major platforms.
+  $user_caches = [
+    'apcu_clear_cache',
+    'wincache_ucache_clear',
+    'xcache_clear_cache',
+  ];
+  array_walk(array_filter($user_caches, 'is_callable'), 'call_user_func');
+
   drupal_rebuild($autoloader, $request);
   drupal_set_message('Cache rebuild complete.');
 }