Today I knows that the server never send a request to a client! It just make response~

  So,if the browser always want to get the newest data in the Server, it must regularly send request(always by AJAX) to the Server to get the resouce.

  There comes to a important problem: when AJAX is communicting  in the background,How does the browser know which response belongs to which request???

  from StackOverFlow,I got an excellent answer! 阮一峰的文章也给了很多启发。

  A browser can open one or more connections to a web server in order to request resources. For each of those connections the rules regarding HTTP keep-alive are the same and apply to both HTTP 1.0 and 1.1:

  • If HTTP keep-alive is off, the request is sent by the client, the response is sent by the server, the connection is closed:

    Connection 1: [Open][Request1][Response1][Close]
  • If HTTP keep-alive is on, one "persistent" connection can be reused for succeeding requests. The requests are still issued serially over the same connection, so:

    Connection 1: [Open][Request1][Response1][Request3][Response3][Close]
    Connection 2: [Open][Request2][Response2][Request4][Response4][Close]

  With HTTP Pipelining, introduced with HTTP 1.1, if it is enabled (on most browsers it is by default disabled, because of buggy servers), browsers can issue requests after each other without waiting for the response, but the responses are still returned in the same order as they were requested.

  • This can happen simultaneously over multiple (persistent) connections:

    Connection 1: [Open][Request1][Request2][Response1][Response2][Close]
    Connection 2: [Open][Request3][Request4][Response3][Response4][Close]

  Both approaches (keep-alive and pipelining) still utilize the default "request-response" mechanism of HTTP: each response will arrive in the order of the requests on that same connection. They also have the "head of line blocking" problem: if [Response1] is slow and/or big, it holds up all responses that follow on that connection.

  It does this by giving each fragment an identifier to indicate to which request-response pair it belongs, so the receiver can recompose the message.

最新文章

  1. 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
  2. jdbc在mysql下一次执行多条sql脚本
  3. Tomcat部署web项目,虚拟目录,上下文(Context),WEB-INF,web.xml,servlet,404
  4. UDP 内网穿透 心跳
  5. ContentProvider官方教程(4)ContentResolver权限
  6. PMP考试--关于职业道德
  7. Django 1.6 CBVs
  8. Mac中下载JDK手动更新出现“只支持10.7.3以上的系统版本”问题解决方案
  9. 当使用composer安装组件时提示错误
  10. SpringMVC处理ajax请求的注意事项
  11. 算法提高 金属采集 树形DP
  12. 初学javascript《一》break和continue的标签问题
  13. m文件转换c代码
  14. 日志查看技巧之筛选&去重[排查篇]
  15. django ---Auth模块
  16. [C#]RichTextBox实现拖放
  17. java垃圾回收的回收器
  18. day 112天,爬虫(拉钩网,斗音,GitHub)第二天
  19. 解析苹果的官方例子LazyTableImages实现图片懒加载原理
  20. Python学习笔记015——文件file的常规操作seek()及tell()

热门文章

  1. ROS机器人开发实践学习笔记3
  2. JAVA基础知识|lambda与stream
  3. mysql CONCAT函数
  4. 阶段5 3.微服务项目【学成在线】_day04 页面静态化_17-页面静态化-模板管理-GridFS研究-存文件
  5. Jmeter之分布式部署测试
  6. 用Keras搭建神经网络 简单模版(四)—— RNN Classifier 循环神经网络(手写数字图片识别)
  7. BTE的一些知识
  8. js 匿名函数 js-函数定义方法
  9. 工具 --- Git使用
  10. 基于mysqld_multi实现MySQL多实例配置