Can WebSocket (or can) replace Ajax?

Source: Internet
Author: User
My main language is PHP, this a burst of ideas, Web applications, without regard to compatibility, you can use the socket to replace the work of Ajax?

Is it OK to do this (or should I do that)?
Will performance improve? Will consumption increase?

I hope you can help me to answer (I hope this is not a very stupid question ...), thank you.

Reply content:

My main language is PHP, this a burst of ideas, Web applications, without regard to compatibility, you can use the socket to replace the work of Ajax?

Is it OK to do this (or should I do that)?
Will performance improve? Will consumption increase?

I hope you can help me to answer (I hope this is not a very stupid question ...), thank you.

Yes, the page performance is definitely a boost, because the Socket for HTTP has its own bit, that can hold for a long time, and no head content, these benefits for performance is significantly improved. Consumption, the consumption of the server will certainly be a bit bigger, after all, n access, you have to hold n links, this fact is placed there.

without regard to compatibility.

  • If you have a high demand for real-time, you can consider using WebSocket, because the delay is much lower, such as doing some message push functions, and frequent communication words to maintain a better connection.
  • If you just do a query without timing, you should still use Ajax.

Personal opinion, for reference only ~

Right, now both requirements exist, in order to improve the real-time can only reduce the polling time, the server is too unbearable.

So think of the socket above, the problem is not tried before, and do not know how the actual consumption, no end

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.