【发布时间】:2016-09-21 13:09:39
【问题描述】:
我有几个网站要使用同一个 varnish 实例进行缓存。
我确实使用类似的方式设置了后端:
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;
}
哈希方法看起来像:
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);
}
}
但是,我注意到移动版本的页面在桌面上提供,反之亦然。这发生在具有相同名称的页面上,例如“Default.aspx”。
据我了解,哈希上方的代码应包含主机部分,这不应该发生。我是否遗漏了什么,或者有一些关于如何处理多个网站的建议?
谢谢, 阿尔伯特
【问题讨论】:
标签: caching reverse-proxy varnish varnish-vcl