What happens when you click a link explained in 5 minutes
Backstory
Recently, I was interviewing for a mobile development job that I really want. I’ve interviewed at couple of places so I’m familiar with the usual questions you get in mobile dev interviews (e.g., for-if-while algorithms, the difference between nonatomic and atomic), but during this interview I was thrown a bit for a loop. My first question was about the… internet.
Immediately I realized I didn’t know as much about the internet as I thought I did. I ended up leaning on my knowledge of API’s from a mobile perspective to limp through the question, but I decided to write this blog post in an effort to understand the concepts (and actually remember them) !
What does the internet look like?
When accessing the internet, everything seems very wireless. Especially on a phone, it seems as if you click a link and before you know it, the sky above you has delivered the pictures of bacon-wrapped food that you requested.
In reality, the internet looks like a lot of cables and a lot of servers. For example, the cable path from your computer to to Medium’s servers probably looks like this:
- You computer is connected to your local Internet Service Provider (ISP) who we’ll call ‘Small ISP’
- Small ISP connects to an ISP with a larger coverage area that we’ll call ‘Big ISP’
- Big ISP connects to Medium’s ISPs at an Internet Exchange Point, a hub where ISP cables can meet up and connect
- Medium’s ISP connects to mediums servers
Internationally, data through an extensive network of ~300 undersea cables. Those cables help connect millions of servers around the world that store, manipulate and distribute data.

So what happens when you click a link?
Good question.
Your browser goes to work figuring out where exactly you clicked. It registers the link that you clicked on and gets the uniform resource locator or URL. The URL serves as an address for the information you want to access on the internet. Let’s break down the components of the URL

- The protocol or scheme tells you what protocol should be used to access the resource on the internet
- The domain or host is the website (associated servers) that you are looking to access
- The path identifies the specific domain resource you want to access
- The query string provides a string of information to the domain, either to submit for processing or in order to the information neeeded to execute a search
- Fragments are preceded by a # and prompt your browser to present the information returned by the URL in a specific way
Now that your browser has a URL, it can locate the domain that has the data you are seeking to access. It uses the Domain Name System, or DNS to retrieve or IP address for the website using the URL. IP stands for the Internet Protocol, a system for formatting datagrams (packets) and routing them to their intended internet destinations.
Your browser will now use the IP address it can attempt to connect to the domain. It opens a Transmission Control Protocol (TCP) connection to the domain over IP. There is a TCP three-way handshake in during which
- your browser sends a packet to the domain
- the domain sends a packet back
- your browser send another packet back to the domain so both sides (i.e., your browser and the domain) know they are communicating with each other
With the handshake complete, a connection has been established and we’re ready to start receiving the requested data! Your browser sends a request, in our example an Hypertext Transfer Protocol (HTTP) request, to the domain’s servers. They, in turn, processes that request and begin sending the requisite packets back to your browser.
Your browser now starts to process that data it is receiving and presenting the web page. In the case of accessing a webpage, the first data sent back is usually HyperText Markup Language code (HTML) that your browser renders. Often, the HTML contains URLs to other information the web page needs to be complete (e.g, CSS style sheets, JavaScript libraries). Your browser will retrieve data from those URLs and the process continues until your web page is completely loaded.
That’s what happens when you click a link!