javascript - I have a question about the data size for REST transmission at the front and back ends?
淡淡烟草味
淡淡烟草味 2017-06-12 09:19:43
0
2
810

Just like Zhihu/quora and other websites, when reading user answers or articles, you can use read more or modal to read the entire article.

Now there is a similar business scenario. Each time the front end requests 15 articles from the back end, but my question is that some articles may have tens of thousands of words. In this case, whether the amount of data returned by restful-api is too large.

Since the questioner does not have a deep understanding of concepts such as network data transmission, will returning nearly 100,000 words of data at one time have a lot of impact on network delay? In other words, I only return the first few words of the article each time. When the user clicks read more, the front end will initiate a request to the back end.

淡淡烟草味
淡淡烟草味

reply all(2)
淡淡烟草味

Ignoring network factors, this scenario needs to consider two points
1. Server-side compression algorithm performance
2. Server-side compression algorithm compression rate
Generally, algorithm performance and compression rate are inversely proportional. In the most extreme case, the server does not perform compression, so the compression rate is 100% and the CPU overhead is 0%; on the contrary, the compression rate reaches 0.1% and the CPU overhead is 100%.
Currently, servers will enable gzip compression, and the text compression rate can reach about 15%. Of course, it also depends on the text content. For example, the sorted text compression rate will be higher.
Judging from the business scenario described by the subject, similar to preloading 15 articles, you can make appropriate choices. After all, you must take into account both product experience and user traffic.

Ty80

Then the question is, when you render the page on the server side and you request an article of tens of thousands of words, isn’t the amount of data even larger? Hundreds of thousands of words. A Chinese character is 2 bytes. Hundreds of thousands of words are only a few hundred KB = =How big can it be

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