HTTP协议中GET和POST请求有什么区别?

2024年08月28日 建站教程

HTTP协议中GET和POST请求有什么区别?下面先给大家简单介绍一下示例!

GET请求示例:

GET /user?name=John&age=30 HTTP/1.1

POST请求示例:

POST /user HTTP/1.1
Content-Type: application/x-www-form-urlencoded

name=John&age=30

GET和POST请求参数长度限制不同:

// GET 
http://www.example.com?param1=xxx&...¶mn=xxx

// URL长度上限,参数会被截断

// POST 
POST / HTTP/1.1 
Content-Type: application/x-www-form-urlencoded

param1=xxx&...&paramn=xxx

GET和POST请求缓存区别:

// 第1次GET请求
200 OK  

// 缓存内容

// 第2次GET请求
304 Not Modified  

// POST请求不会被缓存

本文链接:http://so.lmcjl.com/news/11586/

展开阅读全文
相关内容