Keep in touch with php?

I am working on a project and I am constantly pinging a php script for new data, so if I understand this correctly, this means that the PHP ping script runs indefinitely. This works, but I assume this is a huge voltage on the server, and is probably considered ugly and bad practice. Am I right about that?

Is it possible to keep the connection alive with the script and use the php built into the output buffering to clear the content I need, but keep the script working for infinity using some kind of loop, so when new data is available, it can be output. Is this a bad idea?

I'm just looking for input form developers there with a lot of experience.

The last thing ...

Are there other ways to maintain a constant stream of data (excluding technologies such as flash or silverlight)?

+3
source share
5 answers

If what you are currently working on and continues to work when it is tested for the kind of load you can expect in this application, this is not really considered bad practice. It is not a crime to keep it simple if it works. Everything that does what you describe will contradict the texture of the original model of the Internet, so you decide on a shaky territory.

Comet. , - , , , , . , . :

- Comet -, HTTP- - , . . , , Javascript, , .

+4

, php . , - scala erlang, .

0

, . , , - ajax (, getxmlhttpobject iframe, : P). , , , , php , .

0

ajax HTTP- . ajaxpatterns.

0

Source: https://habr.com/ru/post/1707157/


All Articles