private function displayItem(CacheItemInterface $item)
    {
        $isDryRun = $this->config()->isDryRunMode();
        $itemContent = $item->getContent();

        if (empty($itemContent)) {
            $this->log(__METHOD__ . ' Empty cache item found, skipping cache.', print_r($item, true));
            return;
        }

        $this->httpHeaders
            ->setLastModified($item->getLastModified())
            ->setExpires($item->getExpiresAt())
            ->setETag($item->getETagString());

        // Decide if sending headers from Config
        // Send headers (if not disabled) and process If-Modified-Since header
        if ($this->config->isSendHeaders()) {
            $logHeaders = sprintf(
                '%s: %s, %s: %s,%s: %s',
                HttpHeaders::HEADER_LAST_MODIFIED,
                $item->getLastModified()->format(HttpHeaders::DATE_FORMAT_CREATE),
                HttpHeaders::HEADER_EXPIRES,
                $item->getExpiresAt()->format(HttpHeaders::DATE_FORMAT_CREATE),
                HttpHeaders::HEADER_ETAG,
                $item->getETagString()
            );
            $this->log(__METHOD__ . ' uri:' . $_SERVER['REQUEST_URI']
                . '; Headers {' . $logHeaders . '}');

            if (!$isDryRun) {
                $this->httpHeaders->send();
                $this->log(
                    __METHOD__ . ' Headers sent: ' . PHP_EOL . implode(
                        PHP_EOL,
                        $this->httpHeaders->getSentHeaders()
                    )
                );
            }

            // Check if conditions for the If-Modified-Since header are met
            if ($this->httpHeaders->checkIfNotModified()) {
                if (!$isDryRun) {
                    $this->httpHeaders->sendNotModifiedHeader();
                    $this->log(__METHOD__ . ' 304 Not Modified header was set. Exiting w/o content.');
                    $this->log(__METHOD__ . ' Response status: ' . http_response_code());
                    exit();
                }
                $this->log(__METHOD__ . ' 304 Not Modified header was set. Not exiting w/o content - Dry Mode.');
            }
        }

        // Show cached content
        $this->log(__METHOD__ . ' Cache item found: ' . $this->getCurrentKey());
        $this->log(__METHOD__ . ' Response status: ' . http_response_code());

        if (!$isDryRun) {
            echo $itemContent;
            exit();
        }
    }
private function displayItem(CacheItemInterface $item)
    {
        $isDryRun = $this->config()->isDryRunMode();
        $itemContent = $item->getContent();

        if (empty($itemContent)) {
            $this->log(__METHOD__ . ' Empty cache item found, skipping cache.', print_r($item, true));
            return;
        }

        $this->httpHeaders
            ->setLastModified($item->getLastModified())
            ->setExpires($item->getExpiresAt())
            ->setETag($item->getETagString());

        // Decide if sending headers from Config
        // Send headers (if not disabled) and process If-Modified-Since header
        if ($this->config->isSendHeaders()) {
            $logHeaders = sprintf(
                '%s: %s, %s: %s,%s: %s',
                HttpHeaders::HEADER_LAST_MODIFIED,
                $item->getLastModified()->format(HttpHeaders::DATE_FORMAT_CREATE),
                HttpHeaders::HEADER_EXPIRES,
                $item->getExpiresAt()->format(HttpHeaders::DATE_FORMAT_CREATE),
                HttpHeaders::HEADER_ETAG,
                $item->getETagString()
            );
            $this->log(__METHOD__ . ' uri:' . $_SERVER['REQUEST_URI']
                . '; Headers {' . $logHeaders . '}');

            if (!$isDryRun) {
                $this->httpHeaders->send();
                $this->log(
                    __METHOD__ . ' Headers sent: ' . PHP_EOL . implode(
                        PHP_EOL,
                        $this->httpHeaders->getSentHeaders()
                    )
                );
            }

            // Check if conditions for the If-Modified-Since header are met
            if ($this->httpHeaders->checkIfNotModified()) {
                if (!$isDryRun) {
                    $this->httpHeaders->sendNotModifiedHeader();
                    $this->log(__METHOD__ . ' 304 Not Modified header was set. Exiting w/o content.');
                    $this->log(__METHOD__ . ' Response status: ' . http_response_code());
                    exit();
                }
                $this->log(__METHOD__ . ' 304 Not Modified header was set. Not exiting w/o content - Dry Mode.');
            }
        }

        // Show cached content
        $this->log(__METHOD__ . ' Cache item found: ' . $this->getCurrentKey());
        $this->log(__METHOD__ . ' Response status: ' . http_response_code());

        if (!$isDryRun) {
            echo $itemContent;
            exit();
        }
    }
private function displayItem ( CacheItemInterface $ item ) { $ isDryRun = $ this -> config ( ) -> isDryRunMode ( ) ; $ itemContent = $ item -> getContent ( ) ; if ( empty ( $ itemContent ) ) { $ this -> log ( __METHOD__ . ' Empty cache item found, skipping cache.' , print_r ( $ item , true ) ) ; return ; } $ this -> httpHeaders -> setLastModified ( $ item -> getLastModified ( ) ) -> setExpires ( $ item -> getExpiresAt ( ) ) -> setETag ( $ item -> getETagString ( ) ) ; // Decide if sending headers from Config // Send headers (if not disabled) and process If-Modified-Since header if ( $ this -> config -> isSendHeaders ( ) ) { $ logHeaders = sprintf ( '%s: %s, %s: %s,%s: %s' , HttpHeaders :: HEADER_LAST_MODIFIED , $ item -> getLastModified ( ) -> format ( HttpHeaders :: DATE_FORMAT_CREATE ) , HttpHeaders :: HEADER_EXPIRES , $ item -> getExpiresAt ( ) -> format ( HttpHeaders :: DATE_FORMAT_CREATE ) , HttpHeaders :: HEADER_ETAG , $ item -> getETagString ( ) ) ; $ this -> log ( __METHOD__ . ' uri:' . $ _SERVER [ 'REQUEST_URI' ] . '; Headers {' . $ logHeaders . '}' ) ; if ( ! $ isDryRun ) { $ this -> httpHeaders -> send ( ) ; $ this -> log ( __METHOD__ . ' Headers sent: ' . PHP_EOL . implode ( PHP_EOL , $ this -> httpHeaders -> getSentHeaders ( ) ) ) ; } // Check if conditions for the If-Modified-Since header are met if ( $ this -> httpHeaders -> checkIfNotModified ( ) ) { if ( ! $ isDryRun ) { $ this -> httpHeaders -> sendNotModifiedHeader ( ) ; $ this -> log ( __METHOD__ . ' 304 Not Modified header was set. Exiting w/o content.' ) ; $ this -> log ( __METHOD__ . ' Response status: ' . http_response_code ( ) ) ; exit ( ) ; } $ this -> log ( __METHOD__ . ' 304 Not Modified header was set. Not exiting w/o content - Dry Mode.' ) ; } } // Show cached content $ this -> log ( __METHOD__ . ' Cache item found: ' . $ this -> getCurrentKey ( ) ) ; $ this -> log ( __METHOD__ . ' Response status: ' . http_response_code ( ) ) ; if ( ! $ isDryRun ) { echo $ itemContent ; exit ( ) ; } }
Display cache item, send headers if necessary.

@param \PageCache\Storage\CacheItemInterface $item
Display cache item send headers if necessary .