What happens when you make an HTTP request?
Last updated: June 25, 2022
Introduction
Thoughts about an additional resource.
We’ll have to clarify what a “server” is…
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works
- Assuming Browser with well-formed Uniform Resource Identifier/URL.
- A Domain Name is a human-readable address but it is not the actual address of the resource.
- The URL is an alias that acts as a pointer to the true Internet Protocol address and location of the requested resource.
- Has the browser recently visited this address and already determined the IP?
- If not, it will as the operating system if another program has (there’s a host file where they are saved).
- If it has the IP address already – then great.
- If not, it will ask the Internet Service Provider.
- This means that other people may have already requested this and it’s saving all of those connections (scary!)
- If it has the IP address already – then great.
- If not, then it will ask the global authority DNS (look into these details). It will know how to find it (But is the most work)
- that will come back and the ISP will get a taste(for other users), and the OS(for other programs), and the browser etc. those things will all keep that info for next time
- With the IP address in hand, the browser can properly make its HTTP request
- That will go to the ISP
- A range of other intermediate computers along the routing
- The web server will note the request (this is a computer)
- This has a program that will run (“The web server”) / dedicated to serving the files that are requested
- The physical computer is often called a “server” / but it’s just a computer. The program is the server.
- Clarify that… (apache / nginx) (we can build a simple one) (check curl) (create one with PHP)
- It’s waiting for requests.
- It has a bunch of rules
- This has a program that will run (“The web server”) / dedicated to serving the files that are requested
- The HTML could be a file sitting on the file system of that computer
- Or / it could be being created on the fly – based on a set of data/request – or other things – and it will create an HTML file from that
- The browser will receive that HTML file
- It will read the HTML file and create a tree-like structure called the Document Object Model.
- It might be complete
- but it’s likely to reference separate images, CSS, JS – and all other sorts of files
- It will start building the website
- and then – will start requesting the other files
- WHEN does the final paint happen? (look at these details)
- At this point, the website is all loaded – and it will just exist
- But it’s also likely to have lots of scripts that are waiting to see if there will be any input
- At that point, the user can interact with the program in whatever way it’s designed to work
- Clicking a regular link might load a new page just like we’ve described above.
- Clicking a button or adding some text to an input might create new pieces of HTML and insert it into the DOM and update the page