【问题标题】:disable nginx caching for certain file types禁用某些文件类型的 nginx 缓存
【发布时间】:2011-11-16 06:21:27
【问题描述】:

我有 nginx 设置,充当 apache 的反向代理。 但是,我需要禁用 gif 缓存。 我怎样才能在 nginx 上做到这一点?

谢谢

【问题讨论】:

    标签: caching nginx


    【解决方案1】:

    这应该可以解决问题:

    set $no_cache "";
    if ($request_uri ~* \.gif$) {
      set $no_cache "1";
    }
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    

    【讨论】:

    • 谢谢,为我工作。但请注意,那里的每个人,至少在 location 块内的 IF IS EVIL。对于其他所有人,这里是 if:wiki.nginx.org/NginxHttpRewriteModule#if 上的文档。
    • 是的,我已经读过,但从未遇到过这个案例的任何问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    • 2014-04-18
    • 2018-04-02
    相关资源
    最近更新 更多