Drupal caches routes in cache_data. This happens in Drupal\Core\Routing\RouteProvider.

I am looking at a high traffic website with "interactive" search functionality based on a map. When you resize your window or move around in the map, a couple of requests are sent to the server for search results based on the map view.

Nearly all requests will be unique, because the map coordinates are part of the request parameters. This in turn seems to flood the cache_data table. The cache_data table easily grows with 100GB in an hour, so a lot of writes are taking place.

Consequently, the database is very busy.

  1. Is it possible to disable this caching?
  2. If #1 is not possible, is there a way to control the cid of the cached routes? The route cache is essentially useless as it is now, as users never will get a cache hit. The possible combinations of query parameters are simply too big.

1 Answer 1


For high traffics sites in general you would put cache tables in memory (Redis or Memcached). Configure Redis as cache, see https://redis.io/topics/config

In this specific case, unless you want to write your own non-cacheable route provider, you could remove the query string

$request->server->set('QUERY_STRING', '');

in a kernel event request subscriber with a priority >32. You can store the query parameters in a service class property so that the controller can retrieve them later or, if it's not your own controller, you could register a second subscriber in the same class with a lower priority to restore the query string after routing.

Restrict the special query string handling to specific paths, some system routes modify the query parameters during routing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.