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
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.
Yes, multipile PURGE requests return 200.