光油:缓存只有特定的域 [英] Varnish: cache only specific domain

查看:133
本文介绍了光油:缓存只有特定的域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在积极谷歌搜索,但没有运气。

I have been Googling aggressively, but without luck.

我使用的清漆很大的成绩,但我想一个服务器(Apache)上托管多个网站,不光油缓存所有的人。

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.

我可以指定缓存由URL哪些网站?

Can I specify what websites by URL to cache?

感谢

推荐答案

(评论后可进行编辑)的这req.http.host,所以在您的VCL文件(例如default.vcl)做的:

(edited after comment) It's req.http.host, so in your vcl file (e.g. default.vcl) do:

sub vcl_recv {
  # dont cache foo.com or bar.com - optional www
   if (req.http.host ~ "(www\.)?(foo|bar)\.com") {
     pass;
   }
  # cache foobar.com - optional www
   if (req.http.host ~ "(www\.)?foobar\.com") {
     lookup;
   }
}

而在varnish3-VCL:

And in varnish3-vcl:

sub vcl_recv {
  # dont cache foo.com or bar.com - optional www
   if (req.http.host ~ "(www\.)?(foo|bar)\.com") {
     return(pass);
   }
  # cache foobar.com - optional www
   if (req.http.host ~ "(www\.)?foobar\.com") {
     return(lookup);
   }
}

这篇关于光油:缓存只有特定的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆