How the Web Works...
• ☕️ 11 min readI’ve been asked this question during an interview for junior positions and it definitely caught me off guard. The best way to answer this is the simple way thats listed below.
Simple
- A wire in the ground that servers can connect to and commuicate with each other
- Servers have IP addresses (unique) and are given names that are much easier to remember ex. www.google.com
- Clients (computers) are connected to the internet by an ISP (Internet Service Provider)
- Data on the internet is broken down into packets and sent to be put together at tthe end of the line
- IP address and router are how packets end up at tehe right destination
- Everything that touchest he internet directly or indrectly has an IP address
MDN: Deeper Dive
- Routers - directs data packets and makes sure message from one computer arrives at the right destination computer
- IP - Internet Protocol
- Internet and web are not the same thing technically. *Some computers, called web servers, can send messages intelligible to web browsers
- Internet is an infrastructure of copjters, servers, routers, ISP all connected together -*The web is a service built on top of the ingrastructure ex. other services include email, iRC (Internet Relay Chat)
How the web works
Simplified view of what happens when you view a web page in a web browser on your computer or phone.
Web developers will benefit from understanding what’s happening in the background.
Clients & Servers
- Computers connected to the web are called clients and servers
[IMG]
- Clients are typically computers or internet conected devices and web-accessing software available on the devices (web browser)
- Servers are computers that store webpages, sites, or applications.
- When client device wants to access a web page, a copy of the web page is downloaded from the serve onto the client machine to be displayed to the client user’s web browser
The other parts of the tool box
-
Internet connection - allows you to send and receive data on the web
- imagine the web as a raod, on one end is our house (client) and the other end is a store (server)
- basically the street between the house and the store
-
TCP/IP - Transmission control Protocol and Internet Protocol are communication protocols that define how the data should travel across the web
- It like the transport mechanisms that lets you place an order, buy goods, and go to the shop
-
DNS - Domain Name Server are like address books for websites
- When you type a web address to brwoser, the browser looks at DNS to find IP address of the site before it can retrieve it
- The browser needs to find which server the website lines on so i can send HTTP messages to the right place
- ex. looking up address of the shop so you can get to it
-
HTTP - HyperText Transfer Protocol is an application protocol that defines a language for clients and serves to speak to each other
- language you use in the store to order goods
-
Component files - a website is made up of many different files, which are like the different parts of the goods you buy from the shop.
So what happens exactly? (When you type a address into the web browser)
- Browser goes to DNS server, finds reall address (IP address) of the server the website lives on (you find adddress of the shop)
- browser sends HTTP request message to server, asking to send ocpy of website to the client (youto got oth shop and order your goods) This message and all other data sent between client and server is esend scross your internet connection using TCP/IP
- If server approves client request, the server sends the cleint a “200 ok” message saying “ok you can look at website” and then starts sending the website files to the brwoser as a series of small chunks called dat packets (the shop gives you your good and you take them back to the house)
- The browser asembles the small chunks of dat into a complete website and displays it to you (the goods arrive at your door)
DNS Explained
- Real web addresses are IP addresses (ex. 63.245.205.20)
- IP addresses represent a unique location o nthe web but not very easy to remember so Domain Name Servers were invented
Packets Explained
- When data is sent on the web, it is sent as thousand of small chunks so that many differnet web users can download the same website at the same time.