Serving multiple sites from varnish
Albert Tollkuçi
albert.tollkuci at gmail.com
Tue May 24 12:57:03 CEST 2016
Hi,
I have several sites that I want to cache using the same instance of
varnish.
I did setup the backend using something like:
if (req.http.host == "time.ikub.al") {
# Process through time backend
set req.backend_hint = timeserver;
}
if (req.http.host == "m.time.ikub.al") {
# Process through time mobile backend
set req.backend_hint = timemobileserver;
}
and hash method looks like:
sub vcl_hash {
# Called after vcl_recv to create a hash value for the request. This is
used as a key
# to look up the object in Varnish.
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
# hash cookies for requests that have them
if (req.http.Cookie) {
hash_data(req.http.Cookie);
}
}
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".
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?
Thanx,
Albert
--
Web: http://www.tollkuci.com
Follow me on: LinkedIn <http://www.linkedin.com/in/alberttollkuci> Google+
<https://plus.google.com/+AlbertTollku%C3%A7i/posts> Facebook
<https://www.facebook.com/albert.tollkuci> Twitter
<https://twitter.com/AlbertTollkuci> Career 2.0
<http://careers.stackoverflow.com/atollkuci>
------------------------------
Imagination is more important than knowledge
*Albert Einstein*
The three chief virtues of a programmer are: Laziness, Impatience and Hubris
*Larry Wall*
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
*Erwin Rommel*
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.
*Randall E. Stross*
Measuring programming progress by lines of code is like measuring aircraft
building progress by weight.
*Bill Gates*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160524/df6431ea/attachment-0001.html>
More information about the varnish-misc
mailing list