generate_vcl.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:django-cache-headers 作者: praekelt 项目源码 文件源码
def handle(self, *args, **options):
        request = RequestFactory().get("/")
        response = HttpResponse()
        user = User()
        n = 0
        print(TEMPLATE_A)
        for pattern, age, cache_type, dc in rules:
            policy = POLICIES[cache_type]
            policy(request, response, user, age)
            if n == 0:
                print("if", end="")
            else:
                print("else if", end="")
            print(""" (req.url ~ "%s") {""" % pattern.pattern)
            print("""set req.http.Hash-Cookies = "%s";""" % response["X-Hash-Cookies"])
            print("}")
            n += 1
        print(TEMPLATE_B)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号