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'm new to Varnish, and I'm hoping it already does this "out of the box", but I'd like to clarify before I consider using it in production:

Here's my setup:

  1. I have multiple sites running off of the same machine that vary by subdomain (i.e.,, etc.)
  2. Each "site" has a profile picture that has the same name (i.e.,

Will Varnish recognize these as separate resources and cache them accordingly? Or will I need to change something in the VCL to tell it include the full host url when looking up cache hits?

share|improve this question
up vote 1 down vote accepted

They will be cached separately out of the box.

The default code for vcl_hash is what controls this:

sub vcl_hash {
    set req.hash += req.url;
    if ( {
        set req.hash +=;
    } else {
        set req.hash += server.ip;
    return (hash);

As you can see, the hostname is included in the hash if it exists, and if it doesn't, the IP of the server is included.

share|improve this answer
Awesome. I did some tests that seemed to verify that, but I'm glad I was able to confirm it. Thanks! – jerhinesmith Jan 11 '11 at 16:19

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.