3 namespace Drupal\Core\EventSubscriber;
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Core\Routing\RoutingEvents;
7 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10 * Clear cache tags when the router is rebuilt.
12 class CacheRouterRebuildSubscriber implements EventSubscriberInterface {
17 public function onRouterFinished() {
18 // Requested URLs that formerly gave a 403/404 may now be valid.
19 // Also invalidate all cached routing as well as every HTTP response.
20 Cache::invalidateTags(['4xx-response', 'route_match', 'http_response']);
26 public static function getSubscribedEvents() {
28 // Act only when the router rebuild is finished.
29 $events[RoutingEvents::FINISHED][] = ['onRouterFinished', 200];