3 namespace Drupal\dynamic_page_cache\PageCache\ResponsePolicy;
5 use Drupal\Core\PageCache\ResponsePolicyInterface;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Symfony\Component\HttpFoundation\Request;
8 use Symfony\Component\HttpFoundation\Response;
11 * Cache policy for routes with the '_admin_route' option set.
13 * This policy rule denies caching of responses generated for admin routes,
14 * because admin routes have very low cache hit ratios due to low traffic and
17 class DenyAdminRoutes implements ResponsePolicyInterface {
20 * The current route match.
22 * @var \Drupal\Core\Routing\RouteMatchInterface
24 protected $routeMatch;
27 * Constructs a deny admin route page cache policy.
29 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
30 * The current route match.
32 public function __construct(RouteMatchInterface $route_match) {
33 $this->routeMatch = $route_match;
39 public function check(Response $response, Request $request) {
40 if (($route = $this->routeMatch->getRouteObject()) && $route->getOption('_admin_route')) {