protected function fetch(Request $request, $catch = false)
    {
        $subRequest = clone $request;

        // send no head requests because we want content
        if ('HEAD' === $request->getMethod()) {
            $subRequest->setMethod('GET');
        }

        // avoid that the backend sends no content
        $subRequest->headers->remove('if_modified_since');
        $subRequest->headers->remove('if_none_match');

        $response = $this->forward($subRequest, $catch);

        if ($response->isCacheable()) {
            $this->store($request, $response);
        }

        return $response;
    }
protected function fetch(Request $request, $catch = false)
    {
        $subRequest = clone $request;

        // send no head requests because we want content
        if ('HEAD' === $request->getMethod()) {
            $subRequest->setMethod('GET');
        }

        // avoid that the backend sends no content
        $subRequest->headers->remove('if_modified_since');
        $subRequest->headers->remove('if_none_match');

        $response = $this->forward($subRequest, $catch);

        if ($response->isCacheable()) {
            $this->store($request, $response);
        }

        return $response;
    }
protected function fetch ( Request $ request , $ catch = false ) { $ subRequest = clone $ request ; // send no head requests because we want content if ( 'HEAD' === $ request -> getMethod ( ) ) { $ subRequest -> setMethod ( 'GET' ) ; } // avoid that the backend sends no content $ subRequest -> headers -> remove ( 'if_modified_since' ) ; $ subRequest -> headers -> remove ( 'if_none_match' ) ; $ response = $ this -> forward ( $ subRequest , $ catch ) ; if ( $ response -> isCacheable ( ) ) { $ this -> store ( $ request , $ response ) ; } return $ response ; }
Unconditionally fetches a fresh response from the backend and
stores it in the cache if is cacheable.

@param Request $request A Request instance
@param bool    $catch   Whether to process exceptions

@return Response A Response instance
Unconditionally fetches a fresh response from the backend and stores it in the cache if is cacheable .