diff --git a/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php
index 1d7cbb7..17b952e 100644
--- a/core/lib/Drupal/Core/Routing/MatcherDumper.php
+++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php
@@ -152,4 +152,12 @@ public function getRoutes() {
     return $this->routes;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function flush() {
+    return $this->connection->truncate($this->tableName)
+      ->execute();
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php
index d4a464f..3eba1e3 100644
--- a/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php
+++ b/core/lib/Drupal/Core/Routing/MatcherDumperInterface.php
@@ -23,4 +23,9 @@
    */
   public function addRoutes(RouteCollection $routes);
 
+  /**
+   * Flushes all routes.
+   */
+  public function flush();
+
 }
diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php
index eebe414..8fe446a 100644
--- a/core/lib/Drupal/Core/Routing/RouteBuilder.php
+++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php
@@ -103,6 +103,7 @@ public function rebuild() {
       return FALSE;
     }
 
+    $this->dumper->flush();
     $yaml_discovery = $this->getYamlDiscovery();
 
     foreach ($yaml_discovery->findAll() as $provider => $routes) {
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
index 9e05a5c..7ac3dea 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
@@ -184,15 +184,17 @@ public function testRebuildWithStaticModuleRoutes() {
 
     // Ensure that the routes are set to the dumper and dumped.
     $this->dumper->expects($this->at(0))
+      ->method('flush');
+    $this->dumper->expects($this->at(1))
       ->method('addRoutes')
       ->with($routing_fixtures->sampleRouteCollection());
-    $this->dumper->expects($this->at(1))
+    $this->dumper->expects($this->at(2))
       ->method('dump')
       ->with(array('provider' => 'test_module'));
-    $this->dumper->expects($this->at(2))
+    $this->dumper->expects($this->at(3))
       ->method('addRoutes')
       ->with($empty_collection);
-    $this->dumper->expects($this->at(3))
+    $this->dumper->expects($this->at(4))
       ->method('dump')
       ->with(array('provider' => 'dynamic_routes'));
 
@@ -257,9 +259,11 @@ public function testRebuildWithProviderBasedRoutes() {
 
     // Ensure that the routes are set to the dumper and dumped.
     $this->dumper->expects($this->at(0))
+      ->method('flush');
+    $this->dumper->expects($this->at(1))
       ->method('addRoutes')
       ->with($route_collection_filled);
-    $this->dumper->expects($this->at(1))
+    $this->dumper->expects($this->at(2))
       ->method('dump')
       ->with(array('provider' => 'test_module'));
 
