protected function addMetaInformation(Response $response, BlockContextInterface $blockContext, BlockServiceInterface $service)
    {
        // a response exists, use it
        if ($this->lastResponse && $this->lastResponse->isCacheable()) {
            $response->setTtl($this->lastResponse->getTtl());
            $response->setPublic();
        } elseif ($this->lastResponse) { // not cacheable
            $response->setPrivate();
            $response->setTtl(0);
            $response->headers->removeCacheControlDirective('s-maxage');
            $response->headers->removeCacheControlDirective('maxage');
        }

        // no more children available in the stack, reseting the state object
        if (!$blockContext->getBlock()->hasParent()) {
            $this->lastResponse = null;
        } else { // contains a parent so storing the response
            $this->lastResponse = $response;
        }

        return $response;
    }
protected function addMetaInformation(Response $response, BlockContextInterface $blockContext, BlockServiceInterface $service)
    {
        // a response exists, use it
        if ($this->lastResponse && $this->lastResponse->isCacheable()) {
            $response->setTtl($this->lastResponse->getTtl());
            $response->setPublic();
        } elseif ($this->lastResponse) { // not cacheable
            $response->setPrivate();
            $response->setTtl(0);
            $response->headers->removeCacheControlDirective('s-maxage');
            $response->headers->removeCacheControlDirective('maxage');
        }

        // no more children available in the stack, reseting the state object
        if (!$blockContext->getBlock()->hasParent()) {
            $this->lastResponse = null;
        } else { // contains a parent so storing the response
            $this->lastResponse = $response;
        }

        return $response;
    }
protected function addMetaInformation ( Response $ response , BlockContextInterface $ blockContext , BlockServiceInterface $ service ) { // a response exists, use it if ( $ this -> lastResponse && $ this -> lastResponse -> isCacheable ( ) ) { $ response -> setTtl ( $ this -> lastResponse -> getTtl ( ) ) ; $ response -> setPublic ( ) ; } elseif ( $ this -> lastResponse ) { // not cacheable $ response -> setPrivate ( ) ; $ response -> setTtl ( 0 ) ; $ response -> headers -> removeCacheControlDirective ( 's-maxage' ) ; $ response -> headers -> removeCacheControlDirective ( 'maxage' ) ; } // no more children available in the stack, reseting the state object if ( ! $ blockContext -> getBlock ( ) -> hasParent ( ) ) { $ this -> lastResponse = null ; } else { // contains a parent so storing the response $ this -> lastResponse = $ response ; } return $ response ; }
This method is responsible to cascade ttl to the parent block.

@param Response              $response
@param BlockContextInterface $blockContext
@param BlockServiceInterface $service

@return Response
This method is responsible to cascade ttl to the parent block .