Varnishlog: show the hash() data in output

Oh Dear! monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

Image of Mattias Geniar

Mattias Geniar, April 03, 2018

Follow me on Twitter as @mattiasgeniar

Since Varnish 4.x and later, the default varnishlog output doesn’t show the vcl_hash() data anymore.

Your varnishlog will look like this:

-   VCL_call       HASH
-   VCL_return     lookup
-   Hit            103841868
-   VCL_call       HIT
-   VCL_return     deliver

If you’re debugging, this isn’t very useful.

To include the “old” behaviour of Varnish and add all the hash elements as well, start Varnish with the following extra parameter:

-p vsl_mask=+Hash

After a Varnish restart, this will procedure varnishlog output like this:

-   VCL_call       HASH
-   Hash           "/images/path/to/file.jpg%00"
-   Hash           "http%00"
-   Hash           "www.yoursite.tld%00"
-   Hash           "/images/path/to/file.jpg%00"
-   Hash           "www.yoursite.tld%00"
-   VCL_return     lookup
-   VCL_call       MISS

In this example, the hash included:

hash_data(req.url);
hash_data(req.http.X-Forwarded-Proto);
hash_data(req.http.host);
hash_data(req.http.Cookie);

The %00 are null characters to prevent cache-conflicts in case you have hash('123'); hash('456); vs. hash('1'); hash('23456');.

Will you help me share this post?

It would mean a lot to me if you could help share this post on social media. 🤗