What is the difference between asynchronous and synchronous HTTP request?

前端 未结 4 1763
礼貌的吻别
礼貌的吻别 2020-12-04 14:22

What is the difference between asynchronous and synchronous HTTP request?

相关标签:
4条回答
  • 2020-12-04 14:55

    Asynchronous APIs do not block. Every synchronous call waits and blocks for your results to come back. This is just a sleeping thread and wasted computation.

    If you need something to happen, send an asynchronous request and do further computation when the request returns. This means your thread sits idle and can pick up other work.

    Asynchronous requests is the way to scale to thousands of concurrent users.

    0 讨论(0)
  • 2020-12-04 14:56

    Synchronous: A synchronous request blocks the client until operation completes. In such case, javascript engine of the browser is blocked.

    Asynchronous An asynchronous request doesn’t block the client i.e. browser is responsive. At that time, user can perform another operations also. In such case, javascript engine of the browser is not blocked.

    0 讨论(0)
  • 2020-12-04 14:57

    Sachin Gandhwani's answer is very well explained in simple words. In case you are still not convinced with the difference of asynchronous HTTP request and synchronous HTTP request, you can read this - https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests

    0 讨论(0)
  • 2020-12-04 15:04

    Check out Determining synchronous vs. asynchronous in web applications for previous discussion. In short:

    Asynchronous APIs do not block. Every synchronous call waits and blocks for your results to > come back. This is just a sleeping thread and wasted computation.

    0 讨论(0)
提交回复
热议问题