Is the HTTP method PURGE idempotent in Varnish?

前端 未结 2 946
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 02:30

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

相关标签:
2条回答
  • 2020-12-12 02:57

    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.

    0 讨论(0)
  • 2020-12-12 02:57

    Yes, multipile PURGE requests return 200.

    0 讨论(0)
提交回复
热议问题