Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTTP Method: GET compares POST


May 04, 2021 HTML Reference Manual


Table of contents


HTTP Method: GET compares POST


HTTP defines different ways to interact with the server, and the two most commonly used HTTP methods are GET and POST.


What is HTTP?

Hyper-text transfer protocols (HTTP) are designed to ensure communication between clients and servers.

HTTP works as a request-answer protocol between the client and the server. The client is an end user and the server side is a Web site.

The web browser may be a client, and the web application on the computer may also act as a server side.

Example: The client (browser) submits an HTTP request to the server; The response contains status information about the request and what might be requested.

For more information about HTTP, you can refer to the HTTP tutorial on this site!


There are two HTTP request methods: GET and POST

Two of the most commonly used methods for request-response between clients and servers are GET and POST.

  • GET - Request data from a specified resource.
  • POST - Submit the data to be processed to the specified resource.

GET method

Note that the query string (name/value pair) is sent in the URL of the GET request:

/test/demo_form.php ?name1=value1&name2=value2

Some other comments about get requests:

  • GET requests can be cached
  • Get requests remain in the browser history
  • GET requests can be bookmarked
  • GET requests should not be used when processing sensitive data
  • Get requests have a length limit
  • GET requests should only be used to get data back

POST method

Note that the query string (name/value pair) is sent in the HTTP message body of the POST request:

POST /test/demo_form.php HTTP/1.1
Host: w3cschool.cn
name1=value1&name2=value2

Some other comments about post requests:

  • POST requests are not cached
  • POST requests are not retained in the browser history
  • POST cannot be bookmarked
  • POST requests do not require data length

Compare GET with POST

The following table compares two HTTP methods: GET and POST.

GET POST
后退按钮/刷新 无害 数据会被重新提交(浏览器应该告知用户数据会被重新提交)。
书签 可收藏为书签 不可收藏为书签
缓存 能被缓存 不能缓存
编码类型 application/x-www-form-urlencoded application/x-www-form-urlencoded or multipart/form-data。为二进制数据使用多重编码。
历史 参数保留在浏览器历史中。 参数不会保存在浏览器历史中。
对数据长度的限制 是的。当发送数据时,GET 方法向 URL 添加数据;URL 的长度是受限制的(URL 的最大长度是 2048 个字符)。 无限制。
对数据类型的限制 只允许 ASCII 字符。 没有限制。也允许二进制数据。
安全性 与 POST 相比,GET 的安全性较差,因为所发送的数据是 URL 的一部分。

在发送密码或其他敏感信息时绝不要使用 GET !
POST 比 GET 更安全,因为参数不会被保存在浏览器历史或 web 服务器日志中。
可见性 数据在 URL 中对所有人都是可见的。 数据不会显示在 URL 中。


Other HTTP request methods

The following table lists some other HTTP request methods:

方法 描述
HEAD 与 GET 相同,但只返回 HTTP 报头,不返回文档主体。
PUT 上传指定的 URI 表示。
DELETE 删除指定资源。
OPTIONS 返回服务器支持的 HTTP 方法。
CONNECT 把请求连接转换到透明的 TCP/IP 通道。