在数据消耗方面更有效. GET还是POST? [英] What is more efficient in terms of data consumption. GET or POST?

查看:113
本文介绍了在数据消耗方面更有效. GET还是POST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们想将一些数据从设备(IOT)发送到我们的服务器.小号变量(例如10到20),但每秒更新一次. 因此发送到服务器的大号.的时间. (每分钟说60次) 我应该使用什么,以便使用最少的数据包. (使用GPRS发送) GET还是POST?

Assuming we want to send the some data from a device (IOT) to our server. Small no. of variables (say 10 to 20) but updated per second. So sent to the server a large no. of times. (Say 60 times a minute) What should I use so that minimum of my data pack is used. (Sending using GPRS) GET or POST?

推荐答案

更新:

您应该检查以下线程:为什么GET方法比POST更快?

You should check this thread : Why GET method is faster than POST?

事实上POST使用了更多数据,因为标头包含更多信息,例如内容的类型和长度

In fact POST use a little bit more data because the header contain some more info like the type of content and it's length

POST /blog/ HTTP/1.1
Host: host.com
Content-Length: 27
Content-Type: application/x-www-form-urlencoded

name1=value1&name2=value2

OLD:

GET请求:

GET /blog/?name1=value1&name2=value2 HTTP/1.1
Host: host.com

POST请求:

POST /blog/ HTTP/1.1
Host: host.com
name1=value1&name2=value2

如您所见,长度方面并没有太大差异,因此两个请求都应使用相同数量的数据. GET对于网址长度(2048)有一些限制,并且只能包含ASCII

As you can see there is no big difference in term of length so both request should use the same ammount of data. GET have some limitaion for the url length (2048) and it can only contain ASCII

来源: http://blog.teamtreehouse.com /the-definitive-guide-to-vs-post

这篇关于在数据消耗方面更有效. GET还是POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆