非常大的HTTP请求与许多小请求 [英] Very large HTTP request vs many small requests

查看:119
本文介绍了非常大的HTTP请求与许多小请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个2D数组(作为Json)从服务器发送到客户端。它将是大约400x400大小,每个条目大约4个字符的文本。

I need a 2D array (as Json) to be sent from server to client. It would be around 400x400 in size with each entry around 4 characters of text. So that makes it around 640KB of data.

以下哪种极端方法更好?

Which of the following extreme approaches is better ?

    $ b
  1. 我发出400个请求 - 每个请求一行(约1.6 KB)

  1. I make a large HTTP request of all the data at one go.
  2. I make 400 requests - each asking for a single row (around 1.6 KB)

我相信最佳方法会在中间。

I believe optimal approach would be somewhere in middle. Could anyone give me an idea what might be the optimal single request size for this data?

感谢。

推荐答案

除非您处理的是慢(非常缓慢今天的标准)连接和真正需要增量更新,请在一个请求。

Unless you are dealing with slow (very slow by today's standards) connections and really need incremental updates, do it in one request.

这样可以提高压缩响应,并避免其他HTTP请求和响应的开销标题

That gives you better efficiency for compressing the response, and avoids the overhead of the extra HTTP requests and response headers.

这篇关于非常大的HTTP请求与许多小请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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