45

Today when using Postman I noticed the method option of PURGE. I have never encountered it in practice and cannot find the explanation of it's purpose.

What is this method used for, where did it come from, and is there a spec for it somewhere?

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
Sam Berry
  • 7,394
  • 6
  • 40
  • 58
  • 4
    @nos: there *IS* an HTTP `PURGE` verb, it is just not defined in the HTTP RFCs. Some HTTP servers and caching systems, such as Squid and Varnish, actually do implement `PURGE` (see [this](https://www.varnish-cache.org/docs/3.0/tutorial/purging.html)), and even curl supports sending `PURGE` requests (see [this](http://stackoverflow.com/questions/11119786/varnish-purge-using-http-and-regex)). – Remy Lebeau Sep 15 '14 at 21:58
  • @nos I removed the link to ietf to prevent distraction. I'm curious what this verb's business is in HTTP, that is the point of the question. If there is no spec, how did it come about. I'm looking for some kind of explanation as to why this verb is somewhat popular, but not popular enough to be specified. Seems odd and random to me, I don't understand what it is supposed to offer in an API when beside GET/POST/PUT/DELETE etc. – Sam Berry Sep 15 '14 at 22:26
  • Being crude: POST = append, PUT = put, DELETE = dereference, PURGE = ? – Sam Berry Sep 15 '14 at 22:35
  • @RemyLebeau irrelevant - Curl supports sending *any* syntactically valid HTTP method name – Julian Reschke Sep 16 '14 at 05:23
  • @RemyLebeau, if you post your comment here as an answer I will mark it as the accepted answer. – Sam Berry Sep 16 '14 at 13:38
  • Also, they aren't verbs, they are methods. e.g. head & options are not verbs anyways. – Elijah Lynn Feb 18 '16 at 23:48
  • RFC2616 (HTTP/1.1) "method" = 164 results "verb" = 2 results, and those are for 'verbally' and 'verbose'. https://www.ietf.org/rfc/rfc2616.txt – Elijah Lynn Feb 24 '16 at 01:42
  • @ElijahLynn yeah, I can't find any usages in RFCs of "verb". If you would like the points, you should suggest an edit for your catch. – Sam Berry Feb 24 '16 at 19:56

2 Answers2

44

There is an HTTP PURGE method, though it is not defined in the HTTP RFCs (which do allow for custom methods beyond the standard defined methods). Some HTTP servers and caching systems actually do implement PURGE, for instance Squid and Varnish:

Squid: How can I purge an object from my cache?

Varnish: Purging and banning

And it is possible to send PURGE requests with curl, for example:

Varnish purge using HTTP and REGEX

Community
  • 1
  • 1
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 2
    Is there "HTTP" that is not HTTP but is HTTP? If not the RFCs, what defines what is and what isn't HTTP? – bruno Nov 11 '15 at 01:48
  • 4
    The official HTTP specs, RFC 2616 and RFCs 7230-7235, define 8 standard methods, and also allow for custom methods as well: `Method = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT" | extension-method`. Custom methods are supposed to be registered with [IANA](http://www.iana.org/assignments/http-methods/http-methods.xhtml), but `PURGE` is not registered. – Remy Lebeau Nov 11 '15 at 02:58
  • Could you also tell me if it's idempotent? Question: http://stackoverflow.com/questions/35632607/is-the-http-verb-purge-idempotent – Gabe Feb 25 '16 at 17:55
  • 1
    As it's not defined by an RFC, I don't think there can a definitive answer to whether it's idempotent. It will depend on how the specific product / server that you're using it with (e.g. Varnish) chooses to handle it. – Al Rodgers Oct 19 '16 at 16:15
  • 2
    Nginx also uses it for purging content from the cache. – Dineshs91 Mar 02 '17 at 17:40
-4

I use the PURGE method if I need to clear the cach in varnish (at the apache level, before php)

wget --method=PURGE --header "x-purge-token: xxx" -H -S www.excepted.com/a/b/c.html

If you look head response this info is cache

  age: 656
  x-cache: HIT|MISS
  x-cv: ftp.server.com