Answer the question
In order to leave comments, you need to log in
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 :)
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;
Answer the question
In order to leave comments, you need to log in
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.
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 questionAsk a Question
731 491 924 answers to any question