Varnish:仅缓存特定域
我一直在积极地谷歌搜索,但没有运气。
我使用 Varnish 取得了很好的效果,但我想在单个服务器 (Apache) 上托管多个网站,而不用 Varnish 缓存所有网站。
我可以通过 URL 指定要缓存的网站吗?
谢谢
I have been Googling aggressively, but without luck.
I'm using Varnish with great results, but I would like to host multiple websites on a single server (Apache), without Varnish caching all of them.
Can I specify what websites by URL to cache?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(评论后编辑) 它是 req.http.host,因此在您的 vcl 文件(例如 default.vcl)中执行:
在 varnish3-vcl 中:
(edited after comment) It's req.http.host, so in your vcl file (e.g. default.vcl) do:
And in varnish3-vcl:
是的,
在 vcl_recv 中,您只需匹配您不希望缓存并传递它们的主机。像这样的东西(未经测试):
Yes,
in vcl_recv you just match the hosts that you would like not to cache and pass them. Something like this (untested):
对于 Varnish 4,
将查找替换为 hash
default.vcl:
For Varnish 4
replace lookup with hash
default.vcl: