Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
719 views
in Technique[技术] by (71.8m points)

rabbitmq - Is the HTTP method PURGE idempotent in Varnish?

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

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);
}

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...