When an interviewer in Accra asks "what happens when you open a website?", they are checking whether you understand the system you will work in. Knowing this also makes debugging much easier, because you can tell whether a problem is in your code, the network or the server.
The journey of a page
Imagine Fuseini in Wa taps a link to a shop's website.
- The address. The browser looks up the domain name, such as
shop.example.com, using DNS. DNS works like a phone book: it turns the name into the server's numeric address. - The request. The browser sends an HTTP request to that server, saying "please give me this page". Almost every site today uses HTTPS, which encrypts the conversation so no one in between can read or change it.
- The response. The server sends back a response with a status code (200 means OK, 404 means not found, 500 means the server failed) and the HTML of the page.
- More requests. The HTML mentions other files: CSS, JavaScript, images and fonts. The browser requests each of them too.