DEV Community

Cover image for What happens when you type 'google.com' into a browser and press Enter?

What happens when you type 'google.com' into a browser and press Enter?

Anton Frattaroli on July 19, 2018

My most favorite interview question I've come across yet was "You type 'google.com' into a browser address bar and hit <Enter>, what happens ...
Collapse
 
daniel15 profile image
Daniel Lo Nigro • Edited

You could go on for much longer if you also talk about hardware interrupts from the keyboard, and the handling of the WM_KEYDOWN window messages. That is, when you type "google.com" on the keyboard, where do those key presses go? How does the computer read and process them?

For every abstraction layer, there's always a deeper layer that you could explain in more detail. :)

Collapse
 
alephnaught2tog profile image
Max Cerrina

That is, when you type "google.com" on the keyboard, where do those key presses go? How does the computer read and process them?

welp, guess know what rabbithole I'm falling down next

Collapse
 
coolshaurya profile image
Shaurya

You can answer this question for infinitely long -

keyboard and typing physics > brain signals to make you type > psychology about why you typed > your great grandfather's marriage and the quadrillion possibilities and detail since then that made you come to that interview > Infinite āˆž stuff about the creation of the universe. šŸ˜µšŸ˜µšŸ˜µšŸ˜µ

Collapse
 
ibibgor profile image
Oscar

There is a Github repository that deals with that question and tries to be really specific.

GitHub logo alex / what-happens-when

An attempt to answer the age old interview question "What happens when you type google.com into your browser and press enter?"

What happens when...

This repository is an attempt to answer the age-old interview question "What happens when you type google.com into your browser's address box and press enter?"

Except instead of the usual story, we're going to try to answer this question in as much detail as possible. No skipping out on anything.

This is a collaborative process, so dig in and try to help out! There are tons of details missing, just waiting for you to add them! So send us a pull request, please!

This is all licensed under the terms of the Creative Commons Zero license.

Read this in ē®€ä½“äø­ę–‡ (simplified Chinese), ę—„ęœ¬čŖž (Japanese), ķ•œźµ­ģ–“ (Korean) and Spanish. NOTE: these have not been reviewed by the alex/what-happens-when maintainers.

Table of Contents

Collapse
 
alamnr profile image
alamnr

thanks for your nice comment , what happen if you copy n paste following address into your browser and press enter -- alamnr.github.io/profile.html?user...

Collapse
 
bgadrian profile image
Adrian B.G.

As an addition, if you get into the google internal infrastructure, with their multi-layered DNS LB and service LB and front-end proxies you can talk for a few hours, at least :))

A good question indeed. I also realized that I lack in the TLS knowledge, I'll put it in the 1000 long TOREAD list.

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

I thought about including a section on browser mechanics - parse, evaluate, paint. But I didn't originally say anything about that so I deemed it to be out of scope.

Collapse
 
bary822 profile image
Hiroto Fukui šŸ¶

I often ask this question to figure out which layer they have strength of technical knowledge.

If the interviewee talks about network layer longer than others, he probably have great skill on that layer.

Collapse
 
drrial profile image
d3rrila

The question is so incredibly broad and can be answered in so many (correct) ways that I can't see how it would be useful

Collapse
 
ogamita profile image
Pascal Bourguignon • Edited

Ah, but it is a perfect question to learn about the candidate, what he knows, how he thinks, etc. Itā€™s a kind of Rorschach test. Also, a good sieve for two ā€œinterestingā€ categories of people: ā€œI donā€™t knowā€, and ā€œthe browse displays the google search boxā€.

Collapse
 
antogarand profile image
Antony Garand • Edited

The nonce attribute on a script tag is a CSP-related attribute:

developers.google.com/web/fundamen...

To use a nonce, give your script tag a nonce attribute. Its value must match one in the list of trusted sources. For example:

<script nonce=EDNnf03nceIOfn39fn3e9h3sdfa>
  //Some inline code I cant remove yet, but need to asap.
</script>

Now, add the nonce to your script-src directive appended to the nonce- keyword.

Content-Security-Policy: script-src 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa'

Remember that nonces must be regenerated for every page request and they must be unguessable.

It does prevent unsafe script from being executed on the webpage if you have an XSS vulnerability. As the nonce must be present in the CSP header, even if you could inject a script tag it wouldn't be executed.

Also note that it does not always default to http and port 80: If your website is in a HSTS preload list. In the case of google.com, it isn't, but many big websites will.

If a website enforces HSTS, it will only default to HTTPS.

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

I like how that's nested under "fundamentals".

Collapse
 
porkostomus profile image
Bobby Towers • Edited

The tech equivalent of Subway's "How do you make a PB&J sandwich" interview test.

Both are obviously impossible to answer in full detail, so the question then becomes, what details do you choose to focus on?

Collapse
 
dangolant profile image
Daniel Golant

Every time I see a breakdown of this question I am pleasantly surprised about where the author digs in vs skims over. I liked your approach here of writing out an answer off the top of your head and then digging in on what actually happens. I did my own take on this a while back, but I am afraid it came across waaaay more stiff :).

Collapse
 
mangel0111 profile image
miguel-penaloza

Can you try to explain me how to use SOLID in frontend with pure javascript?

Collapse
 
johnmarlin_msft profile image
John Marlin

Everyone forgets the obvious. It will break the Internet. Please don't do it. That wireless black box atop Big Ben will be subjected to bad things.

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

fixing it

Collapse
 
scalardimension profile image
Scalar Waves

And then I would ask "how do the neurons inside your brain react on your intention to google 'cat videos'?".

Collapse
 
federhico profile image
federhico

If you were not a developer, what would you like to be?

Collapse
 
tadaboody profile image
Tomer

Don't forget about all the neat low level stuff that's happening even before you leave the LAN!

Collapse
 
jjjjcccjjf profile image
ļ½…ļ½Žļ½„ļ½ļ½Ž

So what did the interviewer say about your answer?

Great read, thanks for sharing this!

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

"Yeah, that's fine, we got it. Tell me about the last time you had a difficult bug."

Honestly, seemed like he had good questions but wasn't a good interviewer.

Collapse
 
somevlad profile image
Vlad Samoylov

There is a whole github repo describing what happens in such detail that it will make happy any interviewer.

Collapse
 
nellybellyville profile image
Nelly Belly

Can you do an "explain to a 5 year old" what happens when you type google into a browser?!

Collapse
 
guadaran profile image
Guadaran

The First Few Milliseconds of an HTTPS Connection. moserware.com/2009/06/first-few-mi...

Collapse
 
schnubb profile image
Schnubb

Hmm... and I thought you get to the google search. ;)

Collapse
 
luperi profile image
Luca Perico

Good article, just a little note: from an OSI Model point of view, HTTP is placed in the Application layer, not in the Presentation one.