My main language is PHP. I have an idea this time. Can I use socket to replace ajax without considering compatibility? Can I do this (or shouldn't I do it? Will the performance be improved? Will consumption increase? I hope you can answer this question for me... my main language is PHP. I have an idea this time. Can I use socket to replace ajax without considering compatibility?
Can I do this (or shouldn't I do it?
Will the performance be improved? Will consumption increase?
I hope you can answer this question for me (I hope this is not a silly question ...), Thank you.
Reply content:
My main language is PHP. I have an idea this time. Can I use socket to replace ajax without considering compatibility?
Can I do this (or shouldn't I do it?
Will the performance be improved? Will consumption increase?
I hope you can answer this question for me (I hope this is not a silly question ...), Thank you.
Yes, the performance of the page must be improved, because the Socket has its own HTTP, that is, it can be held for a long time, and there is no header content, these benefits are significantly improved for performance. In terms of consumption, the consumption on the server is certainly a little larger. After all, you have to Hold N links for N accesses. This fact is there.
Compatibility is not considered.
- If you have high requirements on real-time performance, you can use websocket because the latency is much lower, such as message pushing and other functions. In addition, it is better to maintain a connection when frequent communication occurs.
- If you just make a query from time to time, you should use ajax.
Personal opinions, for reference only ~
Right, now there are two kinds of requirements. To improve real-time performance, only the polling time can be reduced, and the server cannot afford it.
So I thought of the socket. The problem was that I didn't try it before, and I don't know how to consume it.