开发者

How does the browser/server work together to display an html page?

开发者 https://www.devze.com 2023-01-23 20:06 出处:网络
I get this question a lot =/ But I only know how to answer it at a very high level. From the minute a user enters a URL and hits enter, what happens on the client and server side, and how do reques

I get this question a lot =/

But I only know how to answer it at a very high level.

From the minute a user enters a URL and hits enter, what happens on the client and server side, and how do requests/responses work? How does the server interact with CGI/interpreters?

It would be helpful too if you could direct me to a URL that has this information in detail, or if you can answer it.

When I describe this to people I开发者_开发技巧 always feel like theyre looking for specifics and I'm not giving enough detail.

Thanks!


  1. Client initiates communication (Usually a HTTP GET request)
  2. Server receives REQUEST-HEADER and parses the URL contained within.
  3. Server does a lookup to see if any URL matches locally in a harddrive-folder. If the webserver handles virtual servers like a Microsoft IIS, then it will determin which folder to search after retrieving the "www.domain.com" part from the REQUEST header.
  4. If web-document (HTML file) is found, then Server sends this back as RESPONSE + a HTTP status code (eg. 200 saying: found, this request went well, where as 404 is "didnt find that file")
  5. Client (browser) receives RESPONSE and can now display it as it wants. If it contains a render engine, then it will search for patterns (HTML tags or whatever language) and then display it as such.

This is also called "stateless" as the server closes communication with client after the client has received everything from the reponse-stream.

Therefore the server cannot know if the client is still connected nor if its comming back later. Many servers does provide a session object using cookies or similar to track if its the same client that sends the next REQUEST and if so, allowing more "intelligent" server responses - such as seeking, transactions and logins.


How does the internet work?

HTTP Made Really Easy

The Canonical Document: RFC 2616


The client sends request headers to the server (finds the IP via DNS).

The server software (e.g. Apache) calls CGI if it needs to and prepares the response.

It sends headers back as well as the content.

0

精彩评论

暂无评论...
验证码 换一张
取 消