CsaGuzzleBundle icon indicating copy to clipboard operation
CsaGuzzleBundle copied to clipboard

X-Cache headers in list.html.twig

Open fnash opened this issue 6 years ago • 1 comments

It would be interesting displaying Varnish headers (or custom headers) in the profiler with bootstrap badges. I make many GET requests in my app and it would be nice to easily know which requests made hit/miss from Varnish, with Age and Total-Hits.

Any guidelines to make a PR?

Make a new default middleware available

class VarnishCacheMiddleware extends CacheMiddleware
{
    const DEBUG_HEADER = 'X-Cache';
}

with

# GuzzleCollector

                if ($response->hasHeader('X-Cache') && 'HIT' === $response->getHeaderLine('X-Cache')) {
                    if ($response->hasHeader('Age')) {
                        $req['varnish']['age'] = $response->getHeaderLine('Age');
                    }

                    if ($response->hasHeader('X-Cache-Hits')) {
                        $req['varnish']['hits'] = $response->getHeaderLine('X-Cache-Hits');
                    }
                }

fnash avatar Jan 23 '19 17:01 fnash

Hi @fnash. I guess the better approach might be to provide extension capabilities to the collector, in order to provide means to extend the current one. We could consider registering services associated to a tag, which would extract some additional information from the request, and let one extend the bundle that way.

What could be great would be to have the possibility to add new sections in the profiler page for each "extension".

csarrazi avatar Jan 31 '19 09:01 csarrazi