3 namespace Drupal\Core\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 'no_cache' option set.
13 * This policy rule denies caching of responses generated for routes that have
14 * the 'no_cache' option set to TRUE.
16 class DenyNoCacheRoutes implements ResponsePolicyInterface {
19 * The current route match.
21 * @var \Drupal\Core\Routing\RouteMatchInterface
23 protected $routeMatch;
26 * Constructs a deny node preview page cache policy.
28 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
29 * The current route match.
31 public function __construct(RouteMatchInterface $route_match) {
32 $this->routeMatch = $route_match;
38 public function check(Response $response, Request $request) {
39 if (($route = $this->routeMatch->getRouteObject()) && $route->getOption('no_cache')) {