Determine whether cache should be attempted.

@param string $url
@param string $httpMethod
@return bool
@internal param $variables
432519
public function isCachable(string $url, string $httpMethod) : bool
    {
        return $httpMethod === ClientInterface::HTTP_GET && $this->getCache() !== null;
    }
869648
function isCached()
    {
        $file = $this->cache_dir . '/' . base64_encode($_SERVER['REQUEST_URI']) . '.html';
        if (!file_exists($file))
        {
            return false;
        }
        elseif (filemtime($file) + $this->expire < time())
        {
            return false;
        }
        else
        {
            return true;
        }
    }
952173
public function request($method, $url, $data = null)
    {
        $url = (string)$url;
        $data = array('$data' => $data);

        if (!$this->cache && $this->params['cache']) {
            $client_id = isset($this->params['route']['client'])
                ? $this->params['route']['client']
                : $this->params['client_id'];
            $this->cache = new Cache($client_id, $this->params['cache']);
        }

        try {
            if (!$this->server->connected) {
                if ($this->params['proxy']) {
                    $data = $this->request_proxy_data($data);
                }
                if (!$this->authed) {
                    $data['$client'] = isset($this->params['route']['client'])
                        ? $this->params['route']['client']
                        : $this->params['client_id'];
                    // Perform basic auth by default for secure/non-route based requests
                    if (!isset($this->server->options['clear']) && !isset($this->params['route']['client'])) {
                        $data['$key'] = $this->params['client_key'];
                        if ($this->cache) {
                            $data['$cached'] = $this->cache->get_versions();
                        }
                        if ($this->params['session']) {
                            $data['$session'] = $this->params['session'];
                        }
                    }
                }
                $this->server->connect();
            }
            $result = $this->server->request($method, $url, $data);
        } catch (NetworkException $e) {
            $this->request_rescue($e);
            $result = $this->server->request($method, $url, $data);
        }

        if (isset($result['$auth'])) {
            if (isset($result['$end'])) {
                // Connection ended, retry
                return $this->request($method, $url, $data['$data']);
            } else {
                $result = $this->auth($result['$auth']);
            }
        }

        return $this->response($method, $url, $data, $result);
    }
147145
public Map<String, String> getCachedChallenge(HttpUrl url) {
        if (url == null) {
            return null;
        }
        String authority = getAuthority(url);
        authority = authority.toLowerCase(Locale.ENGLISH);
        return cachedChallenges.get(authority);
    }
1054476
function is_cached( $path, $method = 'GET', $params = array() ) {
			$cache_key = $this->get_cache_key( $path, $method, $params );

			return self::$_cache->has_valid( $cache_key );
		}
841222
public boolean matches(HttpMethod method, String uri) {
        if (this.httpMethod == method) {
            Matcher matcher = regex.matcher(uri);
            return matcher.matches();
        } else {
            return false;
        }
    }
1299667
public static function isResponseCacheable(Google_Http_Request $resp)
  {
    // First, check if the HTTP request was cacheable before inspecting the
    // HTTP response.
    if (false == self::isRequestCacheable($resp)) {
      return false;
    }

    $code = $resp->getResponseHttpCode();
    if (! in_array($code, self::$CACHEABLE_STATUS_CODES)) {
      return false;
    }

    // The resource is uncacheable if the resource is already expired and
    // the resource doesn't have an ETag for revalidation.
    $etag = $resp->getResponseHeader("etag");
    if (self::isExpired($resp) && $etag == false) {
      return false;
    }

    // [rfc2616-14.9.2]  If [no-store is] sent in a response, a cache MUST NOT
    // store any part of either this response or the request that elicited it.
    $cacheControl = $resp->getParsedCacheControl();
    if (isset($cacheControl['no-store'])) {
      return false;
    }

    // Pragma: no-cache is an http request directive, but is occasionally
    // used as a response header incorrectly.
    $pragma = $resp->getResponseHeader('pragma');
    if ($pragma == 'no-cache' || strpos($pragma, 'no-cache') !== false) {
      return false;
    }

    // [rfc2616-14.44] Vary: * is extremely difficult to cache. "It implies that
    // a cache cannot determine from the request headers of a subsequent request
    // whether this response is the appropriate representation."
    // Given this, we deem responses with the Vary header as uncacheable.
    $vary = $resp->getResponseHeader('vary');
    if ($vary) {
      return false;
    }

    return true;
  }
774349
public function iSendARequest($method, $url)
    {
        $url = $this->prepareUrl($url);

        if (version_compare(ClientInterface::VERSION, '6.0', '>=')) {
            $this->request = new Request($method, $url, $this->headers);
        } else {
            $this->request = $this->getClient()->createRequest($method, $url);
            if (!empty($this->headers)) {
                $this->request->addHeaders($this->headers);
            }
        }

        $this->sendRequest();
    }
595643
public function cache()
    {
        foreach($this->getRoutes() as $key => $r) {
            if (!is_string($r['callback'])) {
                throw new Exception(sprintf('Routes cannot contain a Closure/Function callback while caching.'));
            }
        }

        $cacheContent = '<?php return '.var_export($this->getRoutes(), true).';' . PHP_EOL;
        if (false === file_put_contents($this->cacheFile, $cacheContent)) {
            throw new Exception(sprintf('Routes cache file could not be written.'));
        }

        return true;
    }
937522
public boolean matches(HttpMethod httpMethod, String requestUri) {
        if (this.httpMethod == httpMethod) {
            return matches(requestUri);
        }
        return false;
    }
181933
protected void clearDependencyCaches(String url) {
        // Create the Clear Cache URL for the Alfresco Tomcat server
        URL alfrescoTomcatUrl = buildFinalUrl(url);
        if (alfrescoTomcatUrl == null) {
            getLog().error("Could not build clear dependency caches URL for " +
                    refreshWebappName + ", " + getAbortedMsg());
        }

        // Do the refresh
        makePostCall(alfrescoTomcatUrl, null, "Clear Dependency Caches");
    }
1022270
private function storeCachedResponse(Response $response, $method, $url, array $data, array $headers, $minutes)
    {
        if ($this->cache and $minutes > 0)
        {
            $this->cache->storeResponse($response, $method, $url, $data, $headers, $this->basicAuthCredentials, $minutes);
        }
    }
479436
protected function _autoaction($var, $httpMethod = 'get')
    {
        $method = $this->urlToActionName($var, $httpMethod);
        if (method_exists($this, $method)) {
            return $this->$method();
        } else {
            ToroHook::fire('404', array(
                "error" => "Controller ".get_class($this)." does not contain $method action",
                "path_info" => $this->_pathInfo ));
        }
    }
314979
protected function _maybe_refresh_cache( $url ) {
		$cache = Cache::get( $url );

		if ( ! $cache || is_admin() ) {
			Cache::refresh( $url );
		}
	}
1067728
private static function cache(string $url, string $shortUrl = null)
    {
        if ($shortUrl) {
            self::$cache->hset('url', $url, $shortUrl);

            return 0;
        } else {
            $cache = self::$cache->hget('url', $url);

            return $cache;
        }
    }
100600
public static function delete($url, $httpHeaders = array())
    {
        self::prepareRequest($httpHeaders);

        $response = CurlRequest::delete($url, self::$httpHeaders);

        return self::processResponse($response);
    }
747254
private function getAccept($url, $httpHeader = [])
    {
        if (!empty($httpHeader['accept'])) {
            $this->logger->info('Found accept header "{accept}" for url "{url}" from site config', ['accept' => $httpHeader['accept'], 'url' => $url]);

            return $httpHeader['accept'];
        }

        return false;
    }