Varnish 中的 HTTP 方法 PURGE 是幂等的吗? [英] Is the HTTP method PURGE idempotent in Varnish?

查看:36
本文介绍了Varnish 中的 HTTP 方法 PURGE 是幂等的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP 动词 PURGE 是幂等的吗?如果我两次发送相同的 PURGE 请求,我第二次会收到 200 吗?

Is the HTTP verb PURGE idempotent? If I send the same PURGE request twice will I receive 200 the second time?

我有一个微服务,它在将消息发布到兔子队列之前使 Varnish 缓存无效.如果清除失败,我们只需要记录并继续执行.

I have a microservice that invalidates a Varnish cache before publishing a message into a rabbit queue. In case of purge failure our need is to just log and continue the execution.

队列消费者必须从 Varnish 缓存中获取资源的最新状态.如果第一个微服务的第一次清除成功,来自第二个微服务的新清除请求(在实际从 varnish 请求资源之前)会返回成功吗?

The queue consumer has to get the latest status of the resource from the Varnish cache. Will a new purge request (before actually requesting the resource from varnish) from the second microservice return success in case the first purge from the first microservice succeeded?

推荐答案

PURGE 不是标准的 HTTP 方法.它只是在 Varnish VCL 中配置的东西——通常以这种方式或类似方式:

PURGE is not a standard HTTP method. It is just something configured in Varnish VCL - usually in this fashion or similar:

if (req.method == "PURGE") {
        if (!client.ip ~ purge) {
                return(synth(405,"Not allowed."));
        }
        return (purge);
}

(参见:https://www.varnish-cache.org/docs/trunk/users-guide/purging.html)

当您对资源 (URL) 调用 PURGE 时,它将从缓存 (Varnish) 中删除,因此对于同一资源的下一个 GET 请求,Varnish 将调用后端并缓存其响应.如果您随后对该资源再次调用 PURGE,它将再次从缓存中逐出.

When you call PURGE on a resource (URL) it will be removed from the cache (Varnish) so for the next GET request on the same resource Varnish will call the backend and cache its response. If you then call PURGE again on this resource it will be evicted from the cache again.

这篇关于Varnish 中的 HTTP 方法 PURGE 是幂等的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆