src/Service/ResponseConfigurator.php
public function configure(Response $response, \DateTime $last_modified, $lifetime)
    {
        $request = $this->request_stack->getMasterRequest();

        if (!($request instanceof Request)) {
            return $response;
        }

        // order is important
        $this
            ->setPrivateCache($response, $request)
            ->setLastModified($response, $last_modified)
            ->setLifetime($response, $lifetime)
            ->setEtag($response);

        return $response;
    }
public function configure(Response $response, \DateTime $last_modified, $lifetime)
    {
        $request = $this->request_stack->getMasterRequest();

        if (!($request instanceof Request)) {
            return $response;
        }

        // order is important
        $this
            ->setPrivateCache($response, $request)
            ->setLastModified($response, $last_modified)
            ->setLifetime($response, $lifetime)
            ->setEtag($response);

        return $response;
    }
Configure response.

Set $lifetime as < 0 for not set max-age

@param Response $response
@param \DateTime $last_modified
@param int $lifetime

@return Response