Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've several varnish cache servers (v2.1), and I'm looking to add the hostname in the headers in the response from varnish -- so I know which server is (or not) serving cached pages. Upon googling, I found this snippet, but it gives errors:

sub vcl_deliver {
  if (obj.hits > 0) {
    set resp.http.X-MH-Cache ="HIT " obj.hits " "*
    server.hostname* " " resp.http.Age;
  } else {
    set resp.http.X-MH-Cache ="MISS " *server.hostname* ""

I am not tied to this snippet per se. Ideally, I would like to set hostname in the event of a miss or a hit.

I am fairly new to vcl files, so any guidance and assistance would be much appreciated. Many thanks!


share|improve this question
up vote 0 down vote accepted

Stumbled upon this by chance (isn't it always that way?): -- exactly what I was looking for.

share|improve this answer
This is not a correct answer (linking to documentation) – younes0 Nov 13 '15 at 18:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.