Summary

  • RFC 1945, HTTP/1.0, has no 405. It defines the Allow header as a list of methods a resource supports and 501 as the answer when a server does not recognise a method "and is not capable of supporting it for any resource", which leaves a server no way to say that this particular URL is the problem.
  • RFC 2068 added 405 Method Not Allowed in January 1997 and required the response to include "an Allow header containing a list of valid methods for the requested resource". RFC 7231 then declared both 405 and 501 cacheable by default, and RFC 9110 keeps the rule under the newer name "heuristically cacheable".

In HTTP/1.0 the only excuse was ignorance

Read RFC 1945 and the method vocabulary is already there. The request line carries a method, and §10.1 defines the Allow header: it "lists the set of methods supported by the resource identified by the Request-URI", and its purpose "is strictly to inform the recipient of valid methods associated with the resource". The example is Allow: GET, HEAD. The memo also adds a restriction that later vanishes without explanation: the field is "not permitted in a request using the POST method".

Then comes the gap. HTTP/1.0 defines 400 for a request the server could not understand "due to malformed syntax". It defines 501 Not Implemented as the answer when "the server does not support the functionality required to fulfill the request", and says this is appropriate when the server "does not recognize the request method and is not capable of supporting it for any resource".

The last three words are the problem. A server that understood DELETE perfectly well, and simply did not offer it on /reports/, had nothing to say. Its options were to describe itself as ignorant — 501 — or to call a perfectly well-formed request malformed — 400. The protocol had a word for "I do not know that method" and no word for "not here".

1997: the refusal gains a scope and a receipt

RFC 2068, January 1997, fills the gap with a code that is defined entirely by its scope. "The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource."

Two requirements are packed into that paragraph. The first is the scope: not the server, the resource. The second is the receipt: a 405 is not allowed to be a bare refusal. It must carry the list of methods the resource does accept.

The 501 keeps the other job and keeps the same words it had in HTTP/1.0 — the server "does not recognize the request method and is not capable of supporting it for any resource". Section 14.7 of the same memo states the pairing plainly: "An Allow header field MUST be present in a 405 (Method Not Allowed) response." It also sets the limits of the field. It "cannot prevent a client from trying other methods", the hints "SHOULD be followed", and "the actual set of allowed methods is defined by the origin server at the time of each request".

That last clause is the important one, and it is easy to read past. The method set is not a property of the document, the media type or the URL syntax. It is whatever the origin server decides when the request arrives.

The memo also widens Allow's use: it "MAY be provided with a PUT request to recommend the methods to be supported by the new or modified resource", though the server is not required to support them. So a client could describe the capabilities it wanted for a resource it was creating. The HTTP/1.0 ban on Allow in POST requests is gone by this memo, with no note about why.

What a receipt buys, and what it does not

A 405 plus Allow lets a client learn a resource's method set without the extra round trip of an OPTIONS request, and it lets a proxy pass the answer along unchanged: the memo requires a proxy not to modify the field even if it does not understand every method listed. That is an unusual instruction. It tells an intermediary to carry a list of capabilities it cannot evaluate.

The receipt has a second property that matters more than the first. It is a statement about a configuration, phrased as a statement about a resource. The configuration is the origin server's, it can change, and the client has no way to know when it did.

2014: both refusals become storable

RFC 7231, June 2014, keeps the definitions and adds the sentence that turns them into cache objects. The 405 "indicates that the method received in the request-line is known by the origin server but not supported by the target resource", the origin server "MUST generate an Allow header field", and "A 405 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls".

The 501 gets the same treatment: same definition, "and A 501 response is cacheable by default" under the same conditions.

The same memo improves Allow in two ways, and both make the cached copy more consequential. An origin server "MUST generate an Allow field in a 405 response and MAY do so in any other response" — so the list can now appear on a successful answer, where a cache is even more likely to keep it. And: "An empty Allow field value indicates that the resource allows no methods, which might occur in a 405 response if the resource has been temporarily disabled by configuration."

Read those two sentences together. A resource can be switched off for maintenance, answer 405 with an empty Allow, and that answer is cacheable by default. The protocol has provided a precise way to say "nothing works here right now" and made the statement storable.

The receipt outlives the configuration

RFC 9110, 2022, restates the rule in the modern vocabulary: the 405 "is heuristically cacheable; i.e., unless otherwise indicated by the method definition or explicit cache controls". The rename does not change the outcome. A shared cache may reuse the answer without asking again.

That is the whole shape of the thing. HTTP/1.1 turned a refusal into a receipt, and then made the receipt storable. The two decisions are individually sensible. The receipt saves a round trip and tells a client what to try instead. Caching errors saves a round trip too, and a 405 for a fixed resource does not change often.

Put together, they produce the only status code that answers a question about now with a document from earlier, and hands the client the list of what it is missing. A client that reads Allow: GET, HEAD off a cached 405 has learned the resource's method set as of whenever the cache last asked. The origin server may have added PUT that morning.

The protocol's defence is the one it always uses: the cache is allowed to be wrong for a while, and whoever needs certainty sends a request that cannot be answered from a copy. For most URLs nobody bothers. The method list is carried, obeyed, and never re-checked — which is exactly what a receipt is for, and exactly why the date on it matters.