zoukankan      html  css  js  c++  java
  • html请求顺序

    当你第一次请求一个页面,您的浏览器发送一个GET请求到服务器,它返回的HTML浏览器。
    然后启动浏览器解析页面(可能之前所有已返回)。 当它找到服务器)/域或不是一个引用到外部实体,如一个CSS文件,图像文件,脚本文件,一个Flash文件,或其他任何外部的页面(或者在相同的,它准备让进一步的GET请求的资源。 然而,HTTP标准规定,浏览器应该不会让两个以上的并发请求同一个域。 因此,它把每个请求一个特定的域的队列中,每个实体和返回它启动该域下一个在队列中。 所花费的时间为一实体归还取决于它的大小,负载的服务器目前正经历,服务器活动的每一个机之间的机器上运行的浏览器和。 该机器可以列出这些原则在不同的每个请求,以至于一个图像可能从美国旅行我在英国在大西洋,而另一个来自同一服务器出来通过太平洋,亚洲和欧洲,这需要较长时间。 所以,你可能会得到一个类似下面的序列,其中一个页面(按顺序)参考三个脚本文件,图像文件和五,所有不同的大小:1。 的GET script1和script2;队列5要求script3和images1 -。 2。 script2到达(它的script1小于):获取script3,队列images1 - 5。 3。 script1到达;的GET较受欢迎,排队images2 - 5。 4。 较受欢迎到来时,我们专注的GET,队列images3 - 5。 5。 script3未能到达由于网络问题-的GET script3再次(自动重试)。 6。 我们专注于到达时,script3仍然不在这里的GET较受欢迎,排队images4 - 5。 7。 图3到达;的GET image4,script3仍然在队列image5方式。 8。 image4到达的GET image5 9。 image5到达。 10。 script3到达。 总之:任何旧秩序,做这取决于服务器,使网络的其余的正在做什么,以及是否有任何错误,必须重新牵强。 这可能看起来是一个奇怪的做事方式,但它毫不夸张地说是不可能的方式在互联网(不只是在WWW)向工作程度与任何可靠性如果它没有这样做。 另外,浏览器的内部队列可能不能获取页面的实体,他们的顺序出现在-它不是由任何规定标准。 (哦,不要忘了网络缓存,无论是在浏览器加载缓存和代理中所使用的互联网服务供应商,以纾缓。)

    转载+翻译

    Nicholas Morgan wrote:
    > Does anyone know what the load order for a browser is?
    >
    > 1 HTML
    > 2 CSS
    > 3 IMAGES
    > 4 JS
    > 5 ???
    >

    When you first request a page, your browser sends a GET request to the
    server, which returns the HTML to the browser. The browser then starts
    parsing the page (possibly before all of it has been returned).

    When it finds a reference to an external entity such as a CSS file, an
    image file, a script file, a Flash file, or anything else external to
    the page (either on the same server/domain or not), it prepares to make
    a further GET request for that resource.

    However the HTTP standard specifies that the browser should not make
    more than two concurrent requests to the same domain. So it puts each
    request to a particular domain in a queue, and as each entity is
    returned it starts the next one in the queue for that domain.

    The time it takes for an entity to be returned depends on its size, the
    load the server is currently experiencing, and the activity of every
    single machine between the machine running the browser and the server.
    The list of these machines can in principle be different for every
    request, to the extent that one image might travel from the USA to me in
    the UK over the Atlantic, while another from the same server comes out
    via the Pacific, Asia and Europe, which takes longer. So you might get a
    sequence like the following, where a page has (in this order) references
    to three script files, and five image files, all of differing sizes:

    1. GET script1 and script2; queue request for script3 and images1-5.
    2. script2 arrives (it's smaller than script1): GET script3, queue
    images1-5.
    3. script1 arrives; GET image1, queue images2-5.
    4. image1 arrives, GET image2, queue images3-5.
    5. script3 fails to arrive due to a network problem - GET script3 again
    (automatic retry).
    6. image2 arrives, script3 still not here; GET image3, queue images4-5.
    7. image 3 arrives; GET image4, queue image5, script3 still on the way.
    8. image4 arrives, GET image5;
    9. image5 arrives.
    10. script3 arrives.

    In short: any old order, depending on what the server is doing, what the
    rest of the Internet is doing, and whether or not anything has errors
    and has to be re-fetched. This may seem like a weird way of doing
    things, but it would quite literally be impossible for the Internet (not
    just the WWW) to work with any degree of reliability if it wasn't done
    this way.

    Also, the browser's internal queue might not fetch entities in the order
    they appear in the page - it's not required to by any standard.

    (Oh, and don't forget caching, both in the browser and in caching
    proxies used by ISPs to ease the load on the network.)

    ref:http://archivist.incutio.com/viewlist/css-discuss/76444
  • 相关阅读:
    python 发包爬取中国移动充值页面---可判断手机号是否异常
    python利用selenium和safari浏览器驱动实现新浪微博自动点赞 Demo
    Django学习报错记录
    nginx和tomcat的区别
    Mac主机映射到域名
    mac下eclipse安装svn插件-subclipse
    移动端——等分,居中
    移动端——重置样式
    M端页面-绝对定位布局
    jquery-练习-折叠效果
  • 原文地址:https://www.cnblogs.com/senion/p/1968914.html
Copyright © 2011-2022 走看看