Top 9 HTTP Methods

The HTTP method defines the action the client wants to take on the requested resource at the given URI. HTTP request methods are usually referred to as verbs, although they can also be nouns. Each HTTP method implements different semantics, but some common properties are common to them: for example, they can be secure, idempotent, or cacheable.

Method Action
GET Retrieve information from the server. Should not modify the data on the server. It can be cached, bookmarked, and may remain in the browser history.
HEAD Similar to GET, except it transfers the status line and headers only. Should not modify the data on the server. It cannot be bookmarked and does not remain in the browser history.
POST Send data to the server, including images, JSON strings, file downloads, etc. It cannot be cached, bookmarked, and not stored in the browser history.
PUT Replace or update an existing resource on the server. May change server status. It cannot be cached, bookmarked, and not stored in browser history.
PATCH Partially modify the specified resource on the server. It is faster and requires less resources than the PUT method. It cannot be cached, bookmarked, and not stored in browser history.
DELETE Delete a resource from the server. May change server status. It cannot be cached, bookmarked, and not stored in browser history.
OPTIONS Used by browsers for CORS operations. Describes the communication options available for the requested resource. Does not change data on the server. It cannot be cached, bookmarked, and not stored in browser history.
CONNECT Establishes two-way communication with the server by creating an HTTP tunnel through a proxy server.
TRACE It is designed for diagnostic purposes. When used, the web server sends back to the client the exact request that was received.

See also: HTTP Methods for CRUD Operations.

Safe HTTP Methods

Several common HTTP methods are designed to be safe: GET, HEAD, OPTIONS. Safe methods should not change the state of the server; the operation performed by this method should be read-only. Safe methods are also idempotent.

Idempotent HTTP Methods

The HTTP method is called idempotent if it produces the same result when several identical requests are made. DELETE, GET, HEAD, OPTIONS, PUT and TRACE and idempotent methods.

Cacheable HTTP Methods

An HTTP response is cacheable if it can be stored in the browse's (or proxy server) cache and retrieved later.
  • The response can be cached if the request method is cacheable, for example, GET or HEAD.
  • There should not be specific headers that prevent caching, such as Cache-Control: no-cache.
  • The status code should be cacheable and known by the caching application. For example: 200, 203, 204, 206, 300, and 301.

HTTP Request Methods

List of common HTTP methods, sorted by popularity.

HTTP GET Method

The HTTP GET method requests a representation of the specified resource. The HTTP GET method is safe and idempotent.

HTTP GET Method Example
GET /echo/get/json HTTP/1.1
Host: reqbin.com

Safe Yes
Idempotent Yes
Cacheable Yes
Can have a body No

HTTP POST Method

The HTTP POST method sends or updates data to the server. The type and size of data in the body of the POST message are indicated by the Content-Type and Content-Length headers.

HTTP POST Method Example
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Content-Type: application/json
Content-Length: 81

{POST DATA}

Safe No
Idempotent No
Cacheable No
Can have a body Yes

HTTP HEAD Method

The HEAD method is identical to the GET method, with the only exception that the server sends in response only headers without a response body. The HEAD method is used to test what a GET method will return before actually making a GET request, such as before uploading a large file.

HTTP HEAD Method Example
GET /echo/get/json HTTP/1.1
Host: reqbin.com

Safe Yes
Idempotent Yes
Cacheable Yes
Can have a body No

HTTP PUT Method

The HTTP PUT method is used to create a new resource on the server, or to replace an existing resource with request data. The difference between PUT and POST is that PUT is idempotent.

HTTP PUT Method Example
PUT /echo/put/json/123 HTTP/1.1
Host: reqbin.com
Content-Type: application/json
Content-Length: 81

{PUT DATA}

Safe No
Idempotent Yes
Cacheable No
Can have a body Yes

HTTP DELETE Method

The HTTP DELETE request method deletes the specified resource at the target URL. The DELETE method is idempotent and may have a request body.

HTTP DELETE Method Example
DELETE /echo/delete/json/123 HTTP/1.1
Host: reqbin.com

Safe No
Idempotent Yes
Cacheable No
Can have a body Yes

HTTP PATCH Method

The HTTP PATCH request method applies partial changes to an existing resource on the server. The difference between PATCH and PUT is that PATCH does a partial modification to the resource, while PUT replaces the existing resource with new data.

HTTP PATCH Method Example
PATCH /echo/patch/json/123 HTTP/1.1
Host: reqbin.com
Content-Type: application/json
Content-Length: 81

{PATCH DATA}

Safe No
Idempotent No
Cacheable No
Can have a body Yes

See also

What is HTTP? What is HTTP/2?

Updated: Viewed: 9225 times