DEV Community

Will Vincent
Will Vincent

Posted on • Originally published at wsvincent.com

What Happens When You Type in a URL

"What happens when you type in a URL" is a deceptive question commonly asked in tech interviews. If you look online, there are many very detailed resources but few concise explanations of how a web browser, a server, and the general internet work together.

This is how I would explain it:

  1. You enter a URL into a web browser
  2. The browser looks up the IP address for the domain name via DNS
  3. The browser sends a HTTP request to the server
  4. The server sends back a HTTP response
  5. The browser begins rendering the HTML
  6. The browser sends requests for additional objects embedded in HTML (images, css, JavaScript) and repeats steps 3-5.
  7. Once the page is loaded, the browser sends further async requests as needed.

That's really it. Here's a description in words for this site.

When you type "https://wsvincent.com" into your browser the first thing that happens is a Domain Name Server (DNS) matches "wsvincent.com" to an IP address. Then the browser sends an HTTP request to the server and the server sends back an HTTP response. The browser begins rendering the HTML on the page while also requesting any additional resources such as CSS, JavaScript, images, etc. Each subsequent request completes a request/response cycle and is rendered in turn by the browser. Then once the page is loaded some sites (though not mine) will make further asynchronous requests.

If I were asked to explain further I might start talking about how the server and browser connect via TCP. And we could discuss encryption via https, too.

But fundamentally, it's only 7 steps. I hope this clears up any confusion for readers.

Top comments (3)

Collapse
 
jjokah profile image
John Johnson Okah

Nicely simplified..
But what of in the django world?
something like:
when you type a url, it checks out

  • urls.py which leads you to views.py
  • then views.py does a magical combo (with models.py and and others)
  • and finally gives you a HttpResponse (probably as a template .html)
Collapse
 
wsvincent profile image
Will Vincent • Edited

Well stated. That's about how I'd describe it as well. I think that flow is one of the hardest things to internalize for Django newcomers: you need 4 independent files to create one dynamic web page!

Collapse
 
titanhero profile image
Lex

Very cool explanation 😁✌️👍