title: varnish 4 to cache from multiple servers with different content
body: <p>Using varnish 4 to cache different content of same request from multiple servers. It looks like it caches the first request from one server and keeps giving the same content for every subsequent request. </p>
  
  <p>doing curl gives response with two caches and different age.</p>
  
  <p>Are there any factors like load or anything else for stickiness behaviour?
  Used Jmeter and apache benchmark with load but still got the same behaviour.</p>
  
  <p>Is my vcl_hash is good? Want to save the object with hash combination of url and ip of backend server.</p>
  
  <p>Atleast in my case, looks like after the ttl of the cache object, varnish is caching from second server and returns the same until ttl is done. But this is not what we expect it to behave?</p>
  
  <p>am I missing anything?</p>
  
  <p>using round robin and hash_data. below is my config.vcl</p>
  
  <pre><code>backend s1{
      .host = "190.120.90.1";
  }
  
  backend s2{
      .host = "190.120.90.2";
  }
  
  sub vcl_init {
      new vms = directors.round_robin();
      vms.add_backend(s1);
      vms.add_backend(s2);
  }
  
  sub vcl_recv {
      set req.backend_hint = vms.backend();
  }
  
  sub vcl_hash {
      hash_data(req.url);
      if (req.http.host) {
          hash_data(req.http.host);
      } else {
          hash_data(server.ip);
      }
      return(lookup);
  }
  </code></pre>