What is the HTTP method PURGE?
Asked Answered
E

2

50

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?

Emmettemmey answered 15/9, 2014 at 21:52 Comment(8)
@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), and even curl supports sending PURGE requests (see this).Scherer
@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.Emmettemmey
Being crude: POST = append, PUT = put, DELETE = dereference, PURGE = ?Emmettemmey
@RemyLebeau irrelevant - Curl supports sending any syntactically valid HTTP method nameValerie
@RemyLebeau, if you post your comment here as an answer I will mark it as the accepted answer.Emmettemmey
Also, they aren't verbs, they are methods. e.g. head & options are not verbs anyways.Atelier
RFC2616 (HTTP/1.1) "method" = 164 results "verb" = 2 results, and those are for 'verbally' and 'verbose'. ietf.org/rfc/rfc2616.txtAtelier
@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.Emmettemmey
S
47

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

Scherer answered 16/9, 2014 at 15:54 Comment(5)
Is there "HTTP" that is not HTTP but is HTTP? If not the RFCs, what defines what is and what isn't HTTP?Simpson
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, but PURGE is not registered.Scherer
Could you also tell me if it's idempotent? Question: #35633107Henriettahenriette
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.Nimitz
Nginx also uses it for purging content from the cache.Distaff
C
-3

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
Crespi answered 23/6, 2023 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.