【问题标题】:How to use varnish to pass data when the backend is ok && return the last normal beresq when the backend is down?如何在后端正常时使用varnish传递数据&&在后端关闭时返回最后一个正常的beresq?
【发布时间】:2016-11-07 16:16:50
【问题描述】:

我需要 varnish 直接返回数据并在每次后端正常时更新缓存。当后端关闭时,我还需要清漆从缓存中返回最后一个正常的 beresq 数据。我应该如何处理清漆?

【问题讨论】:

    标签: caching varnish varnish-vcl


    【解决方案1】:

    我只是喜欢它。当后端启动时,使用 req.hash_always_miss=true 来传递数据。当后端宕机时,响应 FEATCH_FAILED 并使用 vcl_synth 重新启动 recv。

    vcl 4.0;
    
    backend default {
        .host = "127.0.0.1";
        .port = "4567";
    }
    
    sub vcl_recv {
        if (req.restarts == 0) {
            set req.hash_always_miss=true;
        } else {
            set req.hash_always_miss=false;
        }
    }
    
    sub vcl_backend_error {
        return (abandon);
    }
    
    sub vcl_synth {
        return (restart);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 2020-11-18
      相关资源
      最近更新 更多