How to do the uploading of information, for example, in case of chat, so that every second there is a call to the database for new messages or, for example, who is online? By the word "right", I mean that the minimum load on the site is, I think with the help of ajax, you can call a php script that accesses the database and does what it wants, but I don’t know if it’s right.
1 answer
If the latest trends, then this is applied WebSockets . A persistent connection, through which the server itself can transmit updates when something changes in it, without wasting money on new connections, HTTP headers and the like. And at break or the first input, the current state is synchronized.
If there are no websockets, long polling is applied. If it does not fit, alas, the client must request periodically.
- And how to implement a socket connection on the site? In the programs on the computer, I make a connection socket without any problems, but on the website I don’t know unfortunately: ( - alex-rudenkiy
- But this should already support the site engine. Without knowing which engine, no one will tell you what is needed from it - it’s a trite new version to take, a plug-in ready or seriously to write something. - Netch
- And if there is no engine, the site is from scratch: D - alex-rudenkiy
- First of all, it should support hosting, and then it is already possible to nakostylyat to any engine - andreymal
|