system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: What happens when you type a URL into the browser and hit enter?

I would like to understand how a webpage is rendered. I know that there is a lot more going on in the background other than simply pulling up the page based on the URL you type in...
gpt
First, it has to convert that URL into an actual computer address known as an IP address. The computer will first look to itself for that information. That IP address for that URL may be cached (a temporary storage of recently accessed information) or listed in the computer's hostfile (a permanent file that contains a list of IPs to be associated with various URLs/hostnames).

If the computer cannot find that information locally, then it has to reach out and ask for that information. This is known as a DNS request. DNS stands for "Domain Name Service" and it's how computers find out about each other. Your computer will have, as part of its network configuration, a list of DNS servers that it can ask for information. Those DNS servers will look locally (to see if they have it cached) or ask other DNS servers. At some point you'll either get to a DNS server that has the information cached or you'll get to an authoritative DNS server which exists as the primary source of information about a given domain. The reply then works its way back to the requesting computer.

Your computer now knows the IP address of the web page you're trying to access. It will now see if that computer is online and accepting communication requests. It will attempt to establish a "hand shake" with that computer. Hand shakes consist of three messages between two computers. The first basically asking if the second is there and ready to communicate. The second acknowledging that it is ready and asking if the first is ready. Lastly the first then acknowledges that it is ready. There is also synchronization of communication settings and the such.

To do this, your computer has to know how to reach the website. It first determines whether or not that website is on the same local network. It does this by comparing the website's IP address to the computer's own address and information it has about the network it is on (configured as part of its network settings). If the website is determined to be on the same local network, it will try and communicate directly with it. If the website is determined to be on a remote network (most likely) it will then communicate with a "gateway" (also part of the computer's network configuration) that will pass on, or route, the request to the website's network.

Communication with different points and devices along the way uses a different set of addresses known as MAC addresses. This works similarly to the URL-IP translation above. The computer checks its cache locally to see if it knows the MAC address for that IP, if not it asks and waits for a reply.

Assuming the most likely case, it will work like this:

1. Computer determines the IP is remote. Sends the request via the gateway.
2. Computer sends a request to the gateway using the gateway's MAC address.
3. The gateway looks at the IP and its own routing table and forwards the request to the MAC address of the next router down the line.
4. This continues until you reach network the website is on.
5. The website hears the request and replies back much in the same manner, just in reverse.

Once the handshake is complete, the computers begin communicating. Your computer will send a request for a specific web page (HTTP GET) and the host will acknowledge the request and try and send you the web page or throw back an error if it cannot.