I
I
ixon2015-08-30 11:53:31
PHP
ixon, 2015-08-30 11:53:31

How to make the php code first respond, and only then make any requests and calculations?

There is a small script that accesses vk api using file_get_contents. And there is a cron that calls this script every 30 minutes. The response of this script to cron is completely unimportant, in fact there are none at all. However, often, requests to vk api take too long and a timeout occurs. How can I first answer the cron that the page is loaded, and only then request the vk api and do all sorts of calculations?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2015-08-30
@ixon

if(file_get_contents($url)) {
...
}

D
Dan Ivanov, 2015-08-30
@ptchol

php.net/manual/ru/function.fastcgi-finish-request.php
Just be careful, keepalive backend-frontend will break.

6
65536, 2015-08-30
@65536

Load the page, send an Ajax request for a script from it, which will get into VK

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question