class DenyAdminRoutes
Same name in other branches
- 8.9.x core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php \Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes
- 10 core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php \Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes
- 11.x core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php \Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes
Cache policy for routes with the '_admin_route' option set.
This policy rule denies caching of responses generated for admin routes, because admin routes have very low cache hit ratios due to low traffic and form submissions.
Hierarchy
- class \Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes implements \Drupal\Core\PageCache\ResponsePolicyInterface
Expanded class hierarchy of DenyAdminRoutes
1 string reference to 'DenyAdminRoutes'
- dynamic_page_cache.services.yml in core/
modules/ dynamic_page_cache/ dynamic_page_cache.services.yml - core/modules/dynamic_page_cache/dynamic_page_cache.services.yml
1 service uses DenyAdminRoutes
- dynamic_page_cache_deny_admin_routes in core/
modules/ dynamic_page_cache/ dynamic_page_cache.services.yml - Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes
File
-
core/
modules/ dynamic_page_cache/ src/ PageCache/ ResponsePolicy/ DenyAdminRoutes.php, line 17
Namespace
Drupal\dynamic_page_cache\PageCache\ResponsePolicyView source
class DenyAdminRoutes implements ResponsePolicyInterface {
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a deny admin route page cache policy.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public function check(Response $response, Request $request) {
if (($route = $this->routeMatch
->getRouteObject()) && $route->getOption('_admin_route')) {
return static::DENY;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
DenyAdminRoutes::$routeMatch | protected | property | The current route match. | |
DenyAdminRoutes::check | public | function | Determines whether it is save to store a page in the cache. | Overrides ResponsePolicyInterface::check |
DenyAdminRoutes::__construct | public | function | Constructs a deny admin route page cache policy. | |
ResponsePolicyInterface::DENY | constant | Deny storage of a page in the cache. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.