title: Symfony2 dynamic routing - caching issue
body: <p>I'm trying to create dynamic routes as I have created a CMS where each page created can be associated to a route. I'm using the example from this link - <a href="http://php-and-symfony.matthiasnoback.nl/2012/01/symfony2-dynamically-add-routes/">http://php-and-symfony.matthiasnoback.nl/2012/01/symfony2-dynamically-add-routes/</a> and all works fine, however the routing is cached, therefore one route will work but then the next won't unless I clear the cache. Is it possible to remove just the routing cache at this stage or is there another alternative? I don't want to remove the whole cache directory on each page load as that wouldn't make sense. Here is the example code:</p>
  
  <pre><code>namespace Acme\RoutingBundle\Routing;
  
  use Symfony\Component\Config\Loader\LoaderInterface;
  use Symfony\Component\Config\Loader\LoaderResolver;
  use Symfony\Component\Routing\Route;
  use Symfony\Component\Routing\RouteCollection;
  
  class ExtraLoader implements LoaderInterface
  {
  private $loaded = false;
  
  public function load($resource, $type = null)
  {
      if (true === $this-&gt;loaded) {
          throw new \RuntimeException('Do not add this loader twice');
      }
  
      $routes = new RouteCollection();
  
      $pattern = '/extra';
      $defaults = array(
          '_controller' =&gt; 'AcmeRoutingBundle:Demo:extraRoute',
      );
  
      $route = new Route($pattern, $defaults);
      $routes-&gt;add('extraRoute', $route);
  
      return $routes;
  }
  
  public function supports($resource, $type = null)
  {
      return 'extra' === $type;
  }
  
  public function getResolver()
  {
  }
  
  public function setResolver(LoaderResolver $resolver)
  {
      // irrelevant to us, since we don't need a resolver
  }
  }
  </code></pre>
  
  <p>Then I've made a service for the ExtraLoader:</p>
  
  <pre><code>&lt;!-- in /src/Acme/RoutingBundle/Resources/config/services.xml --&gt;
  &lt;?xml version="1.0" ?&gt;
  &lt;container xmlns="http://symfony.com/schema/dic/services"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://symfony.com/schema/dic/services       http://symfony.com/schema/dic/services/services-1.0.xsd"&gt;
  
      &lt;services&gt;
          &lt;service id="acme.routing_loader" class="Acme\RoutingBundle\Routing\ExtraLoader"&gt;
              &lt;tag name="routing.loader"&gt;&lt;/tag&gt;
          &lt;/service&gt;
      &lt;/services&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>The last thing we need, is a few extra lines in /app/config/routing.yml:</p>
  
  <pre><code>AcmeRoutingBundle:
      resource: .
      type: extra
  </code></pre>