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.

How does a browser know which response belongs to which request?的更多相关文章

  1. Response ServletContext 中文乱码 Request 编码 请求行 共享数据 转发重定向

    Day35  Response 1.1.1 ServletContext概念 u 项目的管理者(上下文对象),服务器启动时,会为每一个项目创建一个对应的ServletContext对象. 1.1.2  ...

  2. response.sendRedirect(url)与request.getRequestDispatcher(url).forward(request,response)的区别

    response.sendRedirect(url)跳转到指定的URL地址,产生一个新的request,所以要传递参数只有在url后加参数,如: url?id=1.request.getRequest ...

  3. 黑马程序员IDEA版JAVA基础班\JavaWeb部分视频\2-10Request和Response\第5节 request登录案例

    用户登录案例需求: 1.编写login.html登录页面 username & password 两个输入框 2.使用Druid数据库连接池技术,操作mysql,day14数据库中user表 ...

  4. Explain in detail the steps/processes that occur from the moment you type a URL in a browser and hit enter

    In an extremely rough and simplified sketch, assuming the simplest possible HTTP request, no proxies ...

  5. net1:post,get方式传值,读写cookie,读XML文件,写script语句,跳转页面,response与request类

    原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...

  6. request 对象和 response 对象

    Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象.和代表响应的response对象 HttpServletResponse HttpServletR ...

  7. response.sendRedirect()与request.getRequestDispatcher().forward()区别

    Servlet中response.sendRedirect()与request.getRequestDispatcher().forward(request,response)这两个对象都可以使页面跳 ...

  8. 过滤器中的chain.doFilter(request,response)

    Servlet中的过滤器Filter是实现了javax.servlet.Filter接口的服务器端程序,主要的用途是过滤字符编码.做一些业务逻辑判断等.其工作原理是,只要你在web.xml文件配置好要 ...

  9. Response.Redirect()、Server.Execute和Server.Transfer的区别

    1.Response.Redirect(): Response.Redirect方法导致浏览器链接到一个指定的URL. 当Response.Redirect()方法被调用时,它会创建一个应答,应答头中 ...

随机推荐

  1. 基于Ryu REST API的VLAN实现

    目录 0.预备知识 1.实验内容 2.编写脚本addflow.sh一步实现流表下发 3.使用api查看流表 4.实验结果 0.预备知识 ryu控制器的API文档:ryu.app.ofctl_rest ...

  2. 网络文件共享服务—vsftpd服务

    文件传输协议(FTP) 文件传输协议:File Transfer Protocol是用于在网络上进行文件传输的一套标准协议,使用客户/服务器模式.它属于网络传输协议的应用层. 服务器端:vsftpd ...

  3. win10+mysql8.0安装

    一.下载 mysql8.0 windows zip包下载地址: https://dev.mysql.com/downloads/mysql/   1540951981(1).png 二.安装 1.解压 ...

  4. SQL-W3School-高级:SQL 通配符

    ylbtech-SQL-W3School-高级:SQL 通配符 1.返回顶部 1. 在搜索数据库中的数据时,您可以使用 SQL 通配符. SQL 通配符 在搜索数据库中的数据时,SQL 通配符可以替代 ...

  5. C++ fill fill_n generate generate_n

    #include <iostream>#include <algorithm>#include <vector>#include <list>#incl ...

  6. cmake log

    20:28:54: 为项目RoboticArmProject_CarTerminal_V20190530执行步骤 ...20:28:54: 正在启动 "/usr/bin/make" ...

  7. 阶段5 3.微服务项目【学成在线】_day05 消息中间件RabbitMQ_1.页面发布-需求分析

    先静态化,并存储到gridFS 然后,发消息给MQ,MQ接收到消息通知给所有监听他的Cms Client. Cms client从gridFS读取页面下载到自己的服务 业务流程如下:1.管理员进入管理 ...

  8. jmeter-显示log的方法,和脚本通用的语法

    beanshell  log日志设置.log日志输出 步骤: 1.从选项-勾选Log Viewer,打开调试窗口 2.选择显示log的等级 3.在脚本中加入要打引的log 如: log.info(‘日 ...

  9. python3 super().__init__() 和 __init__() 的区别

    1.单继承 super().__int__()和 Base.__init__(self)是一样的, super()避免了基类的显式调用. class Base(object): def __init_ ...

  10. eclipse、MyEclipse 修改字符集和JDK

    eclipse 中UTF-8设置 1.windows->Preferences   打开"首选项"对话框: 2.然后,general->Workspace,右 侧Tex ...