我应该使用 Varnish 而不是 nginx 吗?

发布于 2024-09-05 07:40:08 字数 216 浏览 2 评论 0原文

我真的很喜欢 nginx。

但最近我发现 varnish 为您提供了实现智能缓存反转代理层(带有 URL 清除)的机会。我有一个杂种集群,它们非常消耗资源,所以如果这个缓存层可以消除杂种的一些负载,这可能是一件很棒的事情。

我没有找到一种方法来实现与 nginx 相同的缓存层(用于应用程序页面;静态内容当然是可缓存的)。

我应该使用 Varnish 吗?你会推荐什么?

I really like nginx.

But recently I've found that varnish gives you an opportunity to implement smart caching revers proxy layer(with URL purging). I have a cluster of mongrels which are pretty resource-intensive so if this caching layer can remove some load from mongrels this can be a great thing.

I didn't find a way to implement the caching layer(with for application pages; static content is cacheable of course) same with nginx..

Should I use Varnish instead? What would you recommend?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扶醉桌前 2024-09-12 07:40:08

我不知道你所说的“智能”是什么意思,但无论如何,Nginx 从 0.7 分支开始就有缓存。有许多参数需要调整,例如,

  • 您可以为不同的返回代码设置不同的 TTL,
  • 当应用程序没有响应时返回陈旧内容的能力,
  • 可以限制磁盘上缓存的总大小,
  • 您可以定义哪些信息将用于生成缓存密钥。

文档在这里

I do not know what you mean under "smart", but anyway Nginx has caching starting from 0.7 branch. There are many parameters to tune, e.g.

  • you can have various TTLs for different return codes,
  • ability to return stale content when application does not respond
  • possible to limit the total size of the cache on disk
  • you can define what pieces of information will be used to generate a cache key.

The documentation is here

乖乖公主 2024-09-12 07:40:08

如果你只需要非常基本的缓存,Nginx 有一些不错的功能,但是 Varnish 可以让你通过 URL 或标头匹配进行主动清除,边缘包含所以页面的不同部分可以有不同的 TTL,以及许多其他技巧,因为它有一个非常灵活的配置语言。

如果你真的想认真缓存并减少后端的负载,我会选择 varnish,但是设置起来比仅仅在 nginx.conf 中添加一些指令要多得多。

Nginx has some nice features if you just need very basic caching, but Varnish lets you do active purges by URL or header matching, edge side includes so different parts of your pages can have different TTLs, and lots of other trickery because it has a very flexible configuration language.

If you really want to seriously cache and reduce load on your backends, I'd go with varnish, but it's going to be a lot more work to set up than just adding a few directives to your nginx.conf.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文