小编Chr*_*ris的帖子

nginx 反向代理,何时使用缓存 vs 存储?

我正在将我的项目的网络堆栈重组为:nginx -> haproxy -> many (apache/passenger rails) 实例

其中一些目标包括:

  • 页面缓存的单一位置(目前通过每个 apache 机器上的 rails 完成)
  • 更快的静态内容
  • 从内部管道中删除 ssl
  • ip 日志记录(以前由于在 tcp 模式下运行 haproxy 而丢失)

图像/样式表/javascript 资产被缓存缓存,带有适当的标题。我们的页面缓存基于内部参数,不应响应典型的缓存控件。为了达到这些目的,我们的配置看起来像

server {

    ...

    location /really_slow_dynamic_content/ {
        root /var/www/tmp;
        error_page 404 = @fetch;
    }

    location @fetch {
        internal;
        proxy_pass   haproxy_ip;
        proxy_store  /var/www/tmp${uri}_cache.html;
        proxy_store_access  user:rw  group:rw  all:r;
    }

    location /assets/ {
        proxy_pass   haproxy_ip;
        proxy_cache  assets;
    }

    location / {
        proxy_pass   haproxy_ip;
    }
}
Run Code Online (Sandbox Code Playgroud)

我不是一个真正的系统管理员,我知道有很多替代/调整/添加可能会有帮助。我也不太明白 proxy_cache 和 proxy_store 之间的区别。所以对于我的实际问题......

在我们将资产移动到 nginx 机器之前,对资产使用 proxy_cache 和对慢速动态内容使用 proxy_store 是否有意义?

此外,如果我应该考虑其他考虑因素或软件,我很想听听它们。谢谢!


自从发布这个问题以来,我意识到我使用的初始配置根本不使用商店,并且(半?) …

nginx

8
推荐指数
1
解决办法
6409
查看次数

标签 统计

nginx ×1