【问题标题】:using the max-age request header使用 max-age 请求标头
【发布时间】:2023-03-12 05:06:01
【问题描述】:

如何配置我的 VLC 以让 Varnish 尊重“Cache-Control max-age”请求标头?

我注意到默认情况下 varnish 会提供缓存的内容,即使我在浏览器中按 F5 也是如此(因此请求“新”副本)。

【问题讨论】:

    标签: varnish varnish-vcl


    【解决方案1】:

    vcl_hit 中,您可以执行以下操作:

    if (req.http.Cache-Control ~ '\no-cache\b`) {
        purge;
        return (restart);
    }
    

    确保您已导入 std vmod

    import std;
    

    【讨论】:

    • 我不喜欢的是 vcl_pass 实际上并没有用新条目更新缓存。有没有办法返回 fetch 命令?
    • 我不知道如何在 vcl_hit 中获取 obj.age,所以我能想到的最好的方法是 no-cache。
    猜你喜欢
    • 2023-03-12
    • 1970-01-01
    • 2012-03-04
    • 2021-06-10
    • 2013-03-12
    • 2017-08-21
    • 2012-03-04
    • 2020-08-11
    • 1970-01-01
    相关资源
    最近更新 更多