3 namespace Drupal\node\PageCache;
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 node preview page.
13 * This policy rule denies caching of responses generated by the
14 * entity.node.preview route.
16 class DenyNodePreview 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 ($this->routeMatch->getRouteName() === 'entity.node.preview') {