1

I have a service based on parsing apache access logs, so I need to log there even when Vanish is turned on.

No I just simply tell Varnish to do not cache specific urls:

if (req.url ~ "(foo|bar)") 
   return(pass);
}

But it's heavy on resources and it should be cached. Is there any posibility to log a request on apache access log when Varnish returns a cached copy to client?

1 Answers1

0

why not just use varnishes logger up front and add to the log on varnish if it was a hit or a miss

https://www.varnish-cache.org/docs/trunk/reference/varnishncsa.html

Look at the following

%{X}x
  Extended variables. Supported variables are:

  Varnish:time_firstbyte
     Time to the first byte from the backend arrived
  Varnish:hitmiss
     Whether the request was a cache hit or miss. Pipe and pass are considered misses.
  Varnish:handling
     How the request was handled, whether it was a cache hit, miss, pass, pipe or error.
  VCL_Log:key
     Output value set by std.log("key:value") in VCL.

By default it'll send everything to stdout.. but you can redirect it

Mike
  • 22,310
  • 7
  • 56
  • 79