<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">Hi,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">I have several sites that I want to cache using the same instance of varnish.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">I did setup the backend using something like:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)"><br></div><div class="gmail_default" style=""><div class="gmail_default" style=""><span style="color:rgb(11,83,148);font-family:verdana,sans-serif"> if (req.http.host == "<a href="http://time.ikub.al">time.ikub.al</a>") {</span><br></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"> # Process through time backend</font></div><div class="gmail_default" style=""><span style="color:rgb(11,83,148);font-family:verdana,sans-serif"> set req.backend_hint = timeserver;</span><br></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"> }</font></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"> if (req.http.host == "<a href="http://m.time.ikub.al">m.time.ikub.al</a>") {</font></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"> # Process through time mobile backend</font></div><div class="gmail_default" style=""><span style="color:rgb(11,83,148);font-family:verdana,sans-serif"> set req.backend_hint = timemobileserver;</span><br></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div class="gmail_default" style=""><font color="#0b5394" face="verdana, sans-serif"> }</font></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small">and hash method looks like:</div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div><div style=""><div style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div style=""><span style="color:rgb(11,83,148);font-family:verdana,sans-serif">sub vcl_hash {</span><br></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> # Called after vcl_recv to create a hash value for the request. This is used as a key</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> # to look up the object in Varnish.</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> hash_data(req.url);</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> if (req.http.host) {</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> hash_data(req.http.host);</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> } else {</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> hash_data(server.ip);</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> }</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"><br></font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> # hash cookies for requests that have them</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> if (req.http.Cookie) {</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> hash_data(req.http.Cookie);</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif"> }</font></div><div style=""><font color="#0b5394" face="verdana, sans-serif">}</font></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small">However, I noticed that pages from mobile version where served when on desktop and vice-versa. This happened on pages with the same name, for example "Default.aspx".</div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small">As I understand the code above the hash should include the host part and this should not happen. Am I missing something, or is there some recommendation on how to handle multiple sites?</div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small">Thanx,</div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small">Albert</div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div></div><div style="color:rgb(11,83,148);font-family:verdana,sans-serif;font-size:small"><br></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><span style="font-size:small;color:rgb(61,133,198);font-family:'trebuchet ms',sans-serif">Web: </span><a href="http://www.tollkuci.com/" style="font-size:small;font-family:'trebuchet ms',sans-serif" target="_blank">http://www.tollkuci.com</a><br></div><div><span style="color:rgb(61,133,198);font-family:'trebuchet ms',sans-serif;font-size:small">Follow me on: </span><a href="http://www.linkedin.com/in/alberttollkuci" style="font-family:Arial,Verdana,sans-serif;font-size:12px;margin:0px;padding:0px;color:rgb(31,162,225);text-decoration:none" target="_blank"><img alt="" height="24" src="http://www.tollkuci.com/blog/IMAGES%2f2014%2f02%2flinkedin_icon.png.jpgx" width="24" style="margin: 2px; padding: 0px; vertical-align: middle;">LinkedIn</a> <a href="https://plus.google.com/+AlbertTollku%C3%A7i/posts" style="font-family:Arial,Verdana,sans-serif;font-size:12px;margin:0px;padding:0px;color:rgb(31,162,225);text-decoration:none" target="_blank"><img alt="" height="24" src="http://www.tollkuci.com/blog/IMAGES%2f2014%2f02%2fgoogleplus-icon.png.jpgx" width="24" style="margin: 2px; padding: 0px; vertical-align: middle;">Google+</a> <a href="https://www.facebook.com/albert.tollkuci" style="font-family:Arial,Verdana,sans-serif;font-size:12px;margin:0px;padding:0px;color:rgb(31,162,225);text-decoration:none" target="_blank"><img alt="" height="24" src="http://www.tollkuci.com/blog/IMAGES%2f2014%2f02%2fFacebook_Icon.png.jpgx" width="24" style="margin: 2px; padding: 0px; vertical-align: middle;">Facebook</a> <a href="https://twitter.com/AlbertTollkuci" style="font-family:Arial,Verdana,sans-serif;font-size:12px;margin:0px;padding:0px;color:rgb(31,162,225);text-decoration:none" target="_blank"><img alt="" height="24" src="http://www.tollkuci.com/blog/IMAGES%2f2014%2f02%2fTwitterIcon.png.jpgx" width="24" style="margin: 2px; padding: 0px; vertical-align: middle;">Twitter</a> <a href="http://careers.stackoverflow.com/atollkuci" style="font-family:Arial,Verdana,sans-serif;font-size:12px;margin:0px;padding:0px;color:rgb(31,162,225);text-decoration:none" target="_blank"><img alt="" height="24" src="http://www.tollkuci.com/blog/IMAGES%2f2014%2f02%2fcareers-icon.png.jpgx" width="24" style="margin: 2px; padding: 0px; vertical-align: middle;">Career 2.0</a></div><font style="font-family:'trebuchet ms',sans-serif;color:rgb(102,102,102)"><hr style="color:rgb(34,34,34);font-family:Arial,Verdana,sans-serif;font-size:12px"><br></font><font style="font-family:'trebuchet ms',sans-serif;color:rgb(102,102,102)"></font></div><font style="font-family:'trebuchet ms',sans-serif;color:rgb(102,102,102)" size="2">Imagination is more important than knowledge<br><i>Albert Einstein</i><br><br>The three chief virtues of a programmer are: Laziness, Impatience and Hubris<br><i>Larry Wall</i><br><br>Men are basically smart or dumb and lazy or ambitious. The dumb and ambitious ones are dangerous and I get rid of them. The dumb and lazy ones I give mundane duties. The smart ambitious ones I put on my staff. The smart and lazy ones I make my commanders<br><i>Erwin Rommel</i><br><br></font><div><font style="font-family:'trebuchet ms',sans-serif;color:rgb(102,102,102)" size="2"><div>The best programmers are not marginally better than merely good ones. They are an order-of-magnitude better, measured by whatever standard: conceptual creativity, speed, ingenuity of design, or problem-solving ability.</div><div><i>Randall E. Stross</i></div><div><br></div><div><div>Measuring programming progress by lines of code is like measuring aircraft building progress by weight.</div><div><i>Bill Gates</i></div></div></font></div></div></div>
</div>