diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index 906febc..5b181c1 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -146,9 +146,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']);
