NoServerError.php 591 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php

/**
 * @file
 * Contains \Drupal\Core\PageCache\ResponsePolicy\NoServerError.
 */

namespace Drupal\Core\PageCache\ResponsePolicy;

use Drupal\Core\PageCache\ResponsePolicyInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * A policy denying caching of a server error (HTTP 5xx) responses.
 */
class NoServerError implements ResponsePolicyInterface {

  /**
   * {@inheritdoc}
   */
  public function check(Response $response, Request $request) {
    if ($response->isServerError()) {
      return static::DENY;
    }
  }

}