Varnish 域名访问没命中?IP可以命中-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

Varnish 域名访问没命中?IP可以命中

hulingjie 2016-03-17 12:56:47 2125

这是我的配置

vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "8001";
}
acl purgers {
    "127.0.0.1";
    "10.45.26.57";
    "47.88.34.74";
}

sub vcl_recv {
    if (req.method == "PURGE") {    # PURGE请求的处理
        if (!client.ip ~ purgers) {
            return(synth(405,"Method not allowed"));
        }
        return(purge);
    }

    # Happens before we check if we have this in cache already.
    #
    # Typically you clean up the request here, removing cookies you don't need,
    # rewriting the request, etc.
}

sub vcl_backend_response {
    # Happens after we have read the response headers from the backend.
    #
    # Here you clean the response headers, removing silly Set-Cookie headers
    # and other mistakes your backend does.
}


sub vcl_deliver {
 if (obj.hits > 0) {
                set resp.http.X-Cache = "HIT via" + " " + obj.hits;

        } else {
                set resp.http.X-Cache = "MISS via" + " " + obj.hits;
        }
    return (deliver);
}
 

IP和可以正常访问,有缓存,但是用域名访问一直都是未命中的状态;

缓存
分享到
取消 提交回答
全部回答(1)
云计算
使用钉钉扫一扫加入圈子
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

推荐文章
相似问题
推荐课程