diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index 53ed626..5ff1f14d 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -142,9 +142,8 @@ public function __construct(Connection $connection, StateInterface $state, Curre
    *      match.
    */
   public function getRouteCollectionForRequest(Request $request) {
-    // Cache both the system path as well as route parameters and matching
-    // routes.
-    $cid = 'route:' . $request->getPathInfo() . ':' . $request->getQueryString();
+    // Cache based on the uri to ensure proper matching of all paths.
+    $cid = 'route:' . $request->getUri();
     if ($cached = $this->cache->get($cid)) {
       $this->currentPath->setPath($cached->data['path'], $request);
       $request->query->replace($cached->data['query']);
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
index d28ca5e..71b35df 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
@@ -452,31 +452,31 @@ public function testRouteCaching() {
     $dumper->dump();
 
     // A simple path.
-    $path = '/path/add/one';
+    $path = 'http://example.com/path/add/one';
     $request = Request::create($path, 'GET');
     $provider->getRouteCollectionForRequest($request);
 
-    $cache = $this->cache->get('route:/path/add/one:');
+    $cache = $this->cache->get('route:' . $path);
     $this->assertEqual('/path/add/one', $cache->data['path']);
     $this->assertEqual([], $cache->data['query']);
     $this->assertEqual(3, count($cache->data['routes']));
 
     // A path with query parameters.
-    $path = '/path/add/one?foo=bar';
+    $path = 'http://example.com/path/add/one?foo=bar';
     $request = Request::create($path, 'GET');
     $provider->getRouteCollectionForRequest($request);
 
-    $cache = $this->cache->get('route:/path/add/one:foo=bar');
+    $cache = $this->cache->get('route:' . $path);
     $this->assertEqual('/path/add/one', $cache->data['path']);
     $this->assertEqual(['foo' => 'bar'], $cache->data['query']);
     $this->assertEqual(3, count($cache->data['routes']));
 
     // A path with placeholders.
-    $path = '/path/1/one';
+    $path = 'http://example.com/path/1/one';
     $request = Request::create($path, 'GET');
     $provider->getRouteCollectionForRequest($request);
 
-    $cache = $this->cache->get('route:/path/1/one:');
+    $cache = $this->cache->get('route:' . $path);
     $this->assertEqual('/path/1/one', $cache->data['path']);
     $this->assertEqual([], $cache->data['query']);
     $this->assertEqual(2, count($cache->data['routes']));
@@ -489,11 +489,11 @@ public function testRouteCaching() {
     $alias_manager = \Drupal::service('path.alias_manager');
     $alias_manager->cacheClear();
 
-    $path = '/path/add-one';
+    $path = 'http://example.com/path/add-one';
     $request = Request::create($path, 'GET');
     $provider->getRouteCollectionForRequest($request);
 
-    $cache = $this->cache->get('route:/path/add-one:');
+    $cache = $this->cache->get('route:' . $path);
     $this->assertEqual('/path/add/one', $cache->data['path']);
     $this->assertEqual([], $cache->data['query']);
     $this->assertEqual(3, count($cache->data['routes']));
