protected function checkCache(
        Response $response,
        string $e_tags,
        int $max_age
    ) {
        $result = $response;

        $cache_method = $this->cache_method;
        if (is_callable($cache_method)) {
            $hash = '"' . $cache_method(serialize($response->body)) . '"';

            if (strpos($e_tags, $hash) !== false) {
                $reuse_headers = Utils::arrayWhitelist(
                    $response->headers,
                    [
                        'Content-Location',
                    ]
                );

                $result = $this->prepareResponse();
                $result->status = HttpResponse::HTTP_NOT_MODIFIED;
                $result->headers = $reuse_headers;
            }

            $result->headers['ETag'] = $hash;
            $result->headers['Cache-Control'] = 'private, max-age=' . $max_age
                . ', must-revalidate';
        } else {
            $this->sendError(
                static::ERROR_INTERNAL_SERVER,
                "Router config 'cache_method' is invalid"
            );
        }

        return $result;
    }
protected function checkCache(
        Response $response,
        string $e_tags,
        int $max_age
    ) {
        $result = $response;

        $cache_method = $this->cache_method;
        if (is_callable($cache_method)) {
            $hash = '"' . $cache_method(serialize($response->body)) . '"';

            if (strpos($e_tags, $hash) !== false) {
                $reuse_headers = Utils::arrayWhitelist(
                    $response->headers,
                    [
                        'Content-Location',
                    ]
                );

                $result = $this->prepareResponse();
                $result->status = HttpResponse::HTTP_NOT_MODIFIED;
                $result->headers = $reuse_headers;
            }

            $result->headers['ETag'] = $hash;
            $result->headers['Cache-Control'] = 'private, max-age=' . $max_age
                . ', must-revalidate';
        } else {
            $this->sendError(
                static::ERROR_INTERNAL_SERVER,
                "Router config 'cache_method' is invalid"
            );
        }

        return $result;
    }
protected function checkCache ( Response $ response , string $ e_tags , int $ max_age ) { $ result = $ response ; $ cache_method = $ this -> cache_method ; if ( is_callable ( $ cache_method ) ) { $ hash = '"' . $ cache_method ( serialize ( $ response -> body ) ) . '"' ; if ( strpos ( $ e_tags , $ hash ) !== false ) { $ reuse_headers = Utils :: arrayWhitelist ( $ response -> headers , [ 'Content-Location' , ] ) ; $ result = $ this -> prepareResponse ( ) ; $ result -> status = HttpResponse :: HTTP_NOT_MODIFIED ; $ result -> headers = $ reuse_headers ; } $ result -> headers [ 'ETag' ] = $ hash ; $ result -> headers [ 'Cache-Control' ] = 'private, max-age=' . $ max_age . ', must-revalidate' ; } else { $ this -> sendError ( static :: ERROR_INTERNAL_SERVER , "Router config 'cache_method' is invalid" ) ; } return $ result ; }
Checks if Response is modified from Client's cache

It adds caching headers

@param Response $response Response to be checked
@param string   $e_tags   Request If-None-Match Header
@param integer  $max_age  Resource max_age

@return Response With caching headers or with Not Modified status

@throws RouterException If 'cache_method' config is invalid
Checks if Response is modified from Client s cache