D
D
Danil Sapegin2017-10-12 05:09:56
PHP
Danil Sapegin, 2017-10-12 05:09:56

Why does the server take a long time to return json?

There is an ajax request to the server .
The result of the request is 3.5 megabytes, it takes a very long time to download . Generation time, unfortunately, cannot be accelerated, because there are requests to third-party resources. Interested in exactly how to speed up the download process :)

59dece11e1374776053505.png
Blue progress bar on the image

Here is the code:

$output = json_encode([$brands, $parts, $theparts_p, $theparts_q]);
$gzipoutput = gzencode($output, 6);
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Pragma: no-cache');
header("Content-type: application/json");
header('Content-Encoding: gzip');
header('Content-Length: '.strlen($gzipoutput));
echo $gzipoutput;


those. a certain array is collected for the response, encoded in json, gzip pressed and sent to the client.

The download time of 3 megabytes is about 1.5 seconds.
Is this normal or am I getting carried away?

I checked all the obvious things like the speed of the server, my Internet, etc. - everything is on top

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-10-12
@ynblpb_spb

3 megabytes in 1.5 seconds is about 20 megabits / sec. Not enough for a local network, but for the Internet, IMHO, quite a decent speed.

A
Alexander Taratin, 2017-10-12
@Taraflex

Switch from json to something else
msgpack.org
bsonspec.org
if the data has a strict schema then
https://developers.google.com/protocol-buffers/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question