views:

101

answers:

2

Hi,

How HTTP request works:(if i have mistake, please write)

  1. user type in browser http://www.website.com
  2. the server send him html page with links to images+css+js files
  3. browser read html and where included images/css/js file send http request to get the file

where browser send request to get file, does he waiting for response or he send request for next file?

Thanks

+1  A: 

The browser usually initiate more than one socket to the target server, and thus getting content on more than one socket at the same time. This can be combined with HTTP Pipelining (what you are asking about), where the browser sends multiple requests on the same socket without waiting for each of their responses.

From Wikipedia page:

HTTP pipelining is a technique in which multiple HTTP requests are written out to a single socket without waiting for the corresponding responses. Pipelining is only supported in HTTP/1.1, not in 1.0.

aularon
Thank you for good answer!
Yosef
+2  A: 

Most browsers will have an internal queue of requests which are handled as follows:

Request the first item. If a fresh copy is in the cache, this will mean a request to the cache. If a stale copy with validation information (last-mod and/or e-tag) this will be a conditional request (the server or proxy may return a 304 indicating the stale copy is actually still fresh). Otherwise an unconditional request.

As rendering of the entity returned requires other entities, these will be put into a queue of needed requests.

Requests in the queue that have already been in that same queue (e.g. if a page uses the same image more than once) will have the same entity immediately used (hence if a URI returns a random image, but you use it more than once in the same page, you will get the same image used).

Requests will be processed immediately, so in the case of a webserver, images, css, etc. will begin downloading before the HTML has finished rendering or indeed, finished downloading.

Requests to the same domain with the same protocol (HTTP or HTTPS) will be pipelined, using a connection that has already been used, rather than opening a new one.

Requests are throttled in two ways: A maximum number of simultaneous requests to the same domain, and a total maximum number of simultaneous requests.

Jon Hanna
Thank you very much Jon!
Yosef