开发者社区> 问答> 正文

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

这是我的配置

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和可以正常访问,有缓存,但是用域名访问一直都是未命中的状态;

展开
收起
hulingjie 2016-03-17 12:56:47 3227 0
1 条回答
写回答
取消 提交回答
  • 建议提交工单售后技术支持 或者点击右侧的“联系我们”会有客服人员帮您快速解决问题的

    2019-10-16 17:01:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
域名大数据的应用 立即下载
“域”见更美好的未来——域名筑梦互联网+ 立即下载
“域”感——《域名投资从入门到精通》 立即下载