How does a web browser request and receive a web page?

Today he asked this interesting question.

Explain in detail the process by which the client machine requests a file (say, file.php) from the server, and then receives this desired file along with its necessary JS / CSS / images / video files and they appear on the client of the browser screen.

Here is what I know and what I said:

So, the request is sent, and then the server sees that the file.php file is being requested, and since it has the .php extension, it first uses the PHP engine to parse any PHP code inside the file, and then this is done once, it returns back to the client computer resulting file file.php (as an answer). The browser then takes this response and parses the HTML and the necessary JS and CSS code, and then displays it in the browser.

My answer is quite simple and not as detailed as it should be. I thought about my answer and asked new questions:

  • What is literally a "request"? Is it basically just a text header file that is sent to the server?

  • How about a "response"? Is the response itself a parsed file.php file that is sent back to the client machine?

  • What if the file.php file contains a link to the script.js file and the style.css file? At what stage are these files returned to the client machine? Do they come in separate headings or what?

  • , , : "... .php, PHP PHP ." , , - PHP, ?

+3
3

, , . , .

1) , , ""? , ?

, HTTP- , , : , , ( , , cookie ..).

2) ""? file.php, ?

. HTTP , : ( , , ..), ( , ...) .
HTML-. CSS Javascript , PNG- , -. , ( ) , .

3) , file.php script.js style.css? ? ?

-, , , . , , . , HTML-, : CSS, Javascript, , - ..
, . CSS , , , , .

4). , , : "... .php, PHP PHP ." , , - PHP, ?

, , ;
.php , PHP .

, . , PHP, (, Ruby on Rails, .NET) -.


, , !
HTTP .

+7

HTTP- GET /index.html HTTP/1.1. -.

HTTP ( ) :

HTTP/1.1 200 OK
Content-Length: 20
Content-Type: text/html; charset=UTF-8

<html>Hello</html>

, - , . - , HTML. , .

- , , PHP. , . () .

- , . , ".php", PHP. -.

+2

, , : URL-

To summarize:
1. Enter the URL into the browser: facebook.com
2. The browser looks up the IP address for the domain name
3. The browser sends an HTTP request to the web server

4. The facebook server responds to a constant redirect
5. The browser follows the migration
6. The server processes the request
7. The server sends an HTML response
8. The browser starts rendering HTML
9. The browser sends requests for objects embedded in HTML
10. The browser sends additional asynchronous requests (AJAX)

+2
source

All Articles