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

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

问题描述

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?

我有一个微服务,可以在将消息发布到Rabbit队列之前使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缓存中获取资源的最新状态. 如果从第一个微服务进行的第一次清除成功,是否会从第二个微服务发出新的清除请求(在实际从清漆中请求资源之前)?

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.

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

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