How to speed up getting data from the API?

There is a code
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.travelpayouts.com/v2/prices/month-matrix?currency=RUS&origin=MOW&destination=LED&show_to_affiliates=true&month=2017-12-13&token=*********");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Access-Token: **********"));
$response = curl_exec($ch);
curl_close($ch);
$products=json_decode($response,true);
?>

 $data) {

echo"";
echo""; echo""; 
}
?>
<table id="example2" class="display">
<thead>
the <tr>
 <th>date of departure </th>
 <th> Price, R.</th>
</tr>
</thead>
<tbody>
the <tr>
<?php foreach ($products['data'] as $destination =--><td>";
echo $data['depart_date'] ;
echo"</td><td>";
echo $data['value'] ;
echo"</td></tr></tbody>
</table>


All is displayed normally, but he is too damn strong strains. How to fix it? Thank you
June 10th 19 at 14:26
5 answers
June 10th 19 at 14:28
Solution
Hire groping man
The best answer - Hazel commented on June 10th 19 at 14:31
in cases where you don't understand how everything works is the best solution to the problem. - gunnar.Barrows commented on June 10th 19 at 14:34
June 10th 19 at 14:30
@sochi-russia
the site has no database.

make. don't know how - learn. don't want to learn - hire a professional.
to explain how php to work with database goes well beyond the question on the toaster.
material online sea.

php.net/manual/ru/intro.mysqli.php
www.mysql.ru/docs/man/Reference.html
Website naked php+html what is mysqli??? Are you talking about guys? No database, no cms, no site - Hazel commented on June 10th 19 at 14:33
Suddenly!
1. Base can be set
2. The base can be rented in the cloud - gunnar.Barrows commented on June 10th 19 at 14:36
Yes let generates the json and stores in the file, lul.
Oh, I remember that in php4.3 in shaggy years wrote entire browser games, files...) - Hazel commented on June 10th 19 at 14:39
June 10th 19 at 14:32
I will sum up all previous answers:

1. You need to use some storage on your server to record data and to give them to the user.
2. The data in the vault will be synced to the API every N time units.
3. As storage can be:
3.1 Relational Database such as Mysql.
3.2 non-Relational Database such as Redis.
3.3 Local cache.

Now if you do not understand or do not know how to do this - click here

And Yes, other SIMPLE options THERE. You cannot just take and speed that you want.
3.3 Local cache. - Hazel commented on June 10th 19 at 14:35
it's about the answer - gunnar.Barrows commented on June 10th 19 at 14:38
June 10th 19 at 14:34
Record the data from the api to the database every n minutes in the crown.
I never worked the dark forest - Hazel commented on June 10th 19 at 14:37
Well here and learn - gunnar.Barrows commented on June 10th 19 at 14:40
Nikita and without crown? - Hazel commented on June 10th 19 at 14:43
a website without a database, on the bare php what kind of crown is it? - albertha.Medhur commented on June 10th 19 at 14:46
No. the longest you need to wait for a response from the api for this it is necessary to record in the database, and to maintain the relevance necessary to update automatically. - terrell_Satterfield commented on June 10th 19 at 14:49
the site has no database. - Hazel commented on June 10th 19 at 14:52
so well it's the reel time API, where data is updated relevant and you offer from old dB to give? - gunnar.Barrows commented on June 10th 19 at 14:55
token your get out of the question. - Hazel commented on June 10th 19 at 14:58
, (((will ship much much server - tom_Dickinson commented on June 10th 19 at 15:01
what exactly is shipping? Rendering HTML table or what? - Hazel commented on June 10th 19 at 15:04
With this code page from 8 to 10 seconds to boot - Hazel commented on June 10th 19 at 15:07
it's not the answer to my question! how could you be sure it is the fault of the IPA? - tom_Dickinson commented on June 10th 19 at 15:10
Maybe you server is dying of load shit-PHP? - Hazel commented on June 10th 19 at 15:13
,

This is the data when the code is 5a344d5dc4944419671691.jpeg

And when it is removed the code
5a344d764281f717926908.jpeg - elliott.Cartwrig commented on June 10th 19 at 15:16
June 10th 19 at 14:36
Well, if the immense fear of using the database you have the symptoms, I would somehow cache stored:
$recivedDataArray = array(....); //What IPAS received
$toCache = serialize($recivedDataArray);
file_put_contents ("cache/".time()."_cache", $toCache);
file_put_contents ("cache/last_cache", $toCache);

That's all business... And the history and recent cache and if you think that file-so you can at least crutch)) Another issue is that it's as if "through the anus", but it's up to each
Why do you think that this is a problem of API at all? - Hazel commented on June 10th 19 at 14:39
Duck, I did not think, just the only option to speed it cache. DB the author is using does not want/is not able/ban... not so important. So I wrote how to be a storage cache without database - gunnar.Barrows commented on June 10th 19 at 14:42
what to accelerate? A request for the data? So if the problem is not that, why all this speed? I don't know the intricacies of PHP, but it looks like he's just dying on its server from this task. What's the one fucking request API? - Hazel commented on June 10th 19 at 14:45
And instead of skull, it is easier to use radishes, isn't it - albertha.Medhur commented on June 10th 19 at 14:48
,
ID
5a344db7cafe9103787303.jpeg

Without the code
5a344dcd8a352361099030.jpeg - terrell_Satterfield commented on June 10th 19 at 14:51
to me it about what does not speak. - Hazel commented on June 10th 19 at 14:54
And how does your code connect to my? Thank you - gunnar.Barrows commented on June 10th 19 at 14:57
the meaning of the caching of results. It is clear that the query itself does not accelerate (at first glance), but caching will enable you to retrieve the data from disk, but not with the API. Ie if on fingers: let's say a system is 100, and the average request rate to API for example is 30 seconds. And so the query will run only if the previous time it took an hour for example, or to produce a result from the cache.
It is clear now? - Hazel commented on June 10th 19 at 15:00
Data changes every 30 minutes - tom_Dickinson commented on June 10th 19 at 15:03
Umm... Well so like everything I wrote... Or what exactly is not clear? - Hazel commented on June 10th 19 at 15:06
well it doesn't really matter... Add to the array with the data timestamp, and there is already check at least 30 minutes, at least 30 days)) - Hazel commented on June 10th 19 at 15:09
if I had to, it was not clear what cache? Lol fuck. Fuck is all he needs, if he server from the PHP rendering is dying but not from the query API? It is clear now? - tom_Dickinson commented on June 10th 19 at 15:12
Not really.
the server from rendering the PHP is dying

Is how is it he manages? - Hazel commented on June 10th 19 at 15:15
Nothing is dying, do not listen to the Trigger, already done that. - elliott.Cartwrig commented on June 10th 19 at 15:18
and, well, excellent) - elliott.Cartwrig commented on June 10th 19 at 15:21

Find more questions by tags APIPHP