3 namespace Drupal\Core\PageCache\RequestPolicy;
5 use Drupal\Core\PageCache\RequestPolicyInterface;
6 use Symfony\Component\HttpFoundation\Request;
9 * Reject when running from the command line or when HTTP method is not safe.
11 * The policy denies caching if the request was initiated from the command line
12 * interface (drush) or the request method is neither GET nor HEAD (see RFC
13 * 2616, section 9.1.1 - Safe Methods).
15 class CommandLineOrUnsafeMethod implements RequestPolicyInterface {
20 public function check(Request $request) {
21 if ($this->isCli() || !$request->isMethodCacheable()) {
27 * Indicates whether this is a CLI request.
29 protected function isCli() {
30 return PHP_SAPI === 'cli';