public function refresh()
    {
        $url = $this->resolver->resolve($this->host, '/*');
        $response = $this->http->options(
            $url,
            [
                'headers' => [
                    'Accept' => 'application/json',
                ],
            ]
        );

        if (
            $response->getStatusCode() !== 200 ||
            !$response->hasHeader('Link')
        ) {
            throw new CapabilitiesException(sprintf(
                'Couldn\'t retrieve "%s" capabilities',
                $this->host
            ));
        }

        foreach ($this->cache->keys() as $key) {
            $this->cache->remove($key);
        }

        $links = Response::parseHeader($response, 'Link');

        foreach ($links as $link) {
            if (isset($link['rel']) && $link['rel'] === 'endpoint') {
                $url = $this->resolver->resolve(
                    $this->host,
                    substr($link[0], 1, -1)
                );
                $this->cache->save($link['name'], $url);
            }
        }

        return $this;
    }