The path_processor_outbound service only work after clearing the cache I tried overwrite all links from my site in Drupal 8 in accordance with a URL parameter.

I use the service path_processor_outbound and implemented the processOutbound() method, extending the OutboundPathProcessorInterface interface.

services.yml

services:
   test_concept.test_concept_sayHelloService:
   class: Drupal\test_concept\Services\TestConceptRepeater
   tags:
      - { name: 'path_processor_inbound', priority: 100 }
      - { name: 'path_processor_outbound', priority: 300 }


Method of my class

public function processOutbound($path, &amp;$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
  $current_uri = \Drupal::request()-&gt;getRequestUri();
  $path_args = explode('/', $current_uri);
  $sede = $path_args[1];
  $path = "/" . $sede . $path;
  return $path;
}


This work very good when reloading the site alter flushing the cache, but when I change the URL parameter and reload the site again, the URLs don't change, even if processOutbound() runs again.  

Is a problem with the cache?
That's because those links get cached and Drupal doesn't know by what to vary those caches.

That's why you receive that additional argument, $bubbleable_metadata. You need to use it to specify that our changes depend on a certain url parameter. See https://www.drupal.org/docs/8/api/cache-api/cache-contexts and https://www.drupal.org/docs/8/api/render-api/cacheability-of-render-arrays.

You need something like this:

if ($bubbleable_metadata) {
  $bubbleable_metadata-&gt;addCacheContexts(['url.query_args:your_parameter']);
}