亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - 服務器端使用json返回數(shù)據,請問大小的極限是多少?
迷茫
迷茫 2017-04-18 10:54:40
0
6
1507

我們想在后端查了服務器之后,返回數(shù)據量未知的json對象(每一條就是一個筆記數(shù)據)給前端。有可能上萬條。

請問這樣靠一個請求返回可以嗎?有沒有字符長度限制?
多謝

迷茫
迷茫

業(yè)精于勤,荒于嬉;行成于思,毀于隨。

reply all(6)
劉奇

There must be some. When it comes to PHP specifically, php.ini has a limit of most post. By default, the maximum data transmission is 8M. If it is converted into characters, it may not be calculated. After all, there are methods for calculating characters in Chinese and English. The difference is that even if the transmission limit is continuously expanded, the number of characters transmitted will still be exceeded, so please transmit tens of thousands of data in segments. Even if the maximum limit is not exceeded, the more data is transmitted, the slower the corresponding speed will be.

大家講道理

There is no clear limit on the size of HTTP response.

  1. Generally, the server returns data to the client. If the server knows the size of the returned content, it can be specified through the Content-Length header.

  2. If the server itself does not know the specific size of data returned to the client (such as streaming data), it can use Chunked Transfer-Encoding to identify it.

However, it is not a good idea for the server to return large segments of JSON, as it will cause the client to take too long to parse, and the user experience is not good. The best way is to paginate/segment the data, asynchronously, and request while parsing.

迷茫

A request returns a large amount of json data, and the front-end parsing time is also very long. If asynchronous processing is not performed, the thread may be stuck. It is best to request in segments

大家講道理

Yes, but you must consider the capabilities of both ends, especially the performance of the server, and the stability of the transmission. Generally speaking this is not recommended.

洪濤

Not recommended, you can use paging and ajax to load

小葫蘆

I object to the previous ones who confused requests and responses.
There is no size limit for downloads. It seems that when you download a file through http request, it will not say that the file cannot be downloaded if it is larger than the size.
Returning json is actually responding to a byte file.
So, unless the php execution times out during your return process, there is no return size problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template