What Are Web Fundamentals?

Key points

  • The Web is something everyone uses as a natural part of daily life β€” for shopping, social media, search, and more.
  • Behind that everyday experience are building blocks like "Request/Response," "Protocol," "Domain," "Cookie," "Session," and "Cache."
  • Let's understand what these elements are made of, and what technology makes them work.

Teacher Pochi uses the Web like this every day, too

πŸ›οΈ Shopping πŸ’¬ Social media πŸ” Search
Request/ResponseI just clicked a button β€” how is data being sent and received behind the scenes? ProtocolWhat's this "http" or "https" at the front? DomainWhy does just typing a URL or domain name take me to the right server? CookieWhy is this information saved even though I'm not logged in? SessionWhy am I still logged in after moving to another page? CacheThis loads faster than the first time I saw it... why?

What is the "Web," anyway?

The Web is a mechanism that lets you view and interact with information stored on servers around the world, through a browser.

It's built on two roles: the "client" (the device or browser the user operates) and the "server" that provides information. The client asks the server, "please give me this information," and the server responds β€” this exchange repeats over and over.

Client
(PC, phone, tablet, etc.)
"Please give me this" β†’
← "Sure, here you go"
Server

Teacher Pochi's hintThis is like walking into a shop, where the staff shows you to a seat and hands you a menu. When your browser visits a server, the server gets the information ready and shows it to you in just the same way.

Requests and responses

The ask a browser sends to a server is called a "request," and the server's reply is called a "response."

Requests come in different "types," called "methods." The two you'll see most are "GET," used to fetch a page's information, and "POST," used to submit form input. Opening this page used GET, for example, while submitting the contact form uses POST.

For example, when you open https://hassan-learning-portal.com/ in a browser, the following four steps happen.

GET
Send request
(no data)
Server prepares
the same HTML
Receive
response
Displayed
on screen
POST
Send request
(data attached)
Server processes
your data
Receive response
with the result
Displayed
on screen

Teacher Pochi's hintWhen you sit down at a restaurant, water and a wet towel show up without you ordering anything β€” that's GET. But your meal only arrives once you actually order it β€” that's POST.

What is HTTP?

HTTP (HyperText Transfer Protocol) is the common rule set (protocol) that browsers and servers use to exchange information. The "request"/"response" exchange from the previous slide, and methods like GET and POST, are all defined within this same set of HTTP rules.

The "http" at the start of a URL means "talk to this URL using the HTTP protocol." "https" means the same thing, but over an encrypted, secure connection (more on that in a later slide).

The server's response comes with a "status code" like the ones below.

200 OKSuccess. "Understood."
400sA problem with the request. "There seems to be an issue with your order." (e.g. 404 Not Found = the page couldn't be found)
500sA problem on the server's end. "We can't help with that right now." (e.g. 500 Internal Server Error = something broke inside the server)

Teacher Pochi's hintThink of a status code as a one-line reply from a shop clerk: "It's ready for you (200)," "There seems to be an issue with your order (400s)," "We can't help with that right now (500s)" β€” each sums up the outcome in a word.

How URLs and domains work

You use URLs every day without a second thought β€” but break one down, and it's actually made up of the following parts.

A URL is like an address that specifies "which server, and which piece of information on it, to access."

https://Protocol
hassan-learning-portal.comDomain
/en/topics/web-fundamentals/overview.htmlPath

The domain is "the server's address," and the path is "where the content lives on that server." Even on the same server (domain), a different path shows a different page. We cover this in more detail in the dedicated domain topic.

Teacher Pochi's hintHere's how I like to picture it: the domain is a "building's address" and the path is "the room number inside the building." Even with the same address (domain), a different room number (path) leads you somewhere different (a different page is shown).

HTTP "doesn't remember state"

HTTP has a property called "stateless," meaning the relationship resets after every single exchange. In other words, a server generally doesn't remember "who sent what a moment ago."

β‘ Client
makes a request
β‘‘Server responds
"nice to meet you"
β‘’Same client
requests again
β‘£Server says
"nice to meet you" again

Even when the request comes from the same client, the server has no way of telling that. But on the Web sites you use every day, that's not actually what happens. Once you log in, you stay logged in, and anything you add to your cart stays right where you left it. A mechanism called a "session" is what makes that possible.

Teacher Pochi's hintPicture a forgetful shop clerk who greets you with "nice to meet you" every single time β€” that's HTTP for you! Since they don't remember what you ordered last time, they can't treat you like a regular customer as things stand.

How session management works

A mechanism called a "session" is what keeps recognizing the same user over time. First, the server issues each user an identifying number called a "session ID" and hands it to the client. The client then includes that session ID in every request from then on, so the server can recognize "oh, it's this same person" each time.

β‘  Server issues
a session ID
β‘‘ Client holds
the session ID
β‘’ Next request includes
the session ID
β‘£ Server
recognizes them

But you probably don't remember ever being told a session ID, or typing one in yourself. And if you were paying close attention to the GET explanation earlier, you might be wondering β€” GET doesn't send any data, so how does the session ID even reach the server? The next slide's "cookie" mechanism answers exactly that.

Teacher Pochi's hintIt's a lot like the number you get at a hospital reception desk. Show that same number at the cashier or the pharmacy window later, and they instantly recognize you as "the same person as before."

The roles of cookies and sessions

A cookie is a mechanism for storing a small piece of data on the browser side. From then on, requests to the matching domain generally have the cookie enclosed alongside them (though an expired cookie, or certain security settings, can stop it from being sent).

Cookies are created per domain, and can be rewritten not just by the server, but from the client side too (e.g. by JavaScript).

The "session ID" from the previous slide is actually stored in this cookie. By keeping the server-issued session ID as a cookie, the client can attach that same session ID to every request from then on.

First visit
β‘  First-time
visit
β‘‘ Server issues
a session ID
β‘’ Sends back a cookie
with the session ID
Every visit after that
β‘  Sends the cookie
with the session ID
β‘‘ Server reads
the cookie's contents
β‘’ Identifies
the user

Together, these two mechanisms make it possible to "move between pages while staying logged in." We cover this in more detail in the dedicated cookie and session topics.

Teacher Pochi's hintIt's a lot like a wristband at an amusement park. At the entrance, they write a number on the wristband and put it on you β€” after that, you don't need to show it deliberately each time; staff just glance at it as you pass through the gate.

The role of caching

A cache is a mechanism that temporarily stores data you've already fetched once, so it can be reused the next time it's needed.

Client-side caching
β‘  1st time:
fetch from the server
β‘‘ Store the
data locally
β‘’ 2nd time onward:
reuse the stored copy
Server-side caching
β‘  1st time:
generate the data
β‘‘ Keep it on
the server
β‘’ 2nd time onward:
reuse the kept copy

There are two kinds of caching: "client-side caching," which keeps data close at hand on your own device, and "server-side caching," which keeps data the server already generated once. Each speeds things up in a different way.

Client-side caching skips the request to the server entirely, since it just redisplays the copy you already have. Server-side caching, on the other hand, shortens the processing time by returning a saved copy instead of regenerating it from scratch every time. We cover this in more detail in the dedicated cache topic.

Teacher Pochi's hintI like to think of it as keeping a stock of seasonings you use often in the kitchen cupboard, instead of going out to buy them every time. What's already on hand can be used right away, saving you the trip (the request to the server).

Summary

The Web is something everyone uses without a second thought β€” for shopping, social media, search, and more. Behind that everyday experience are technologies like "Request/Response," "Protocol," "Domain," "Cookie," "Session," and "Cache."

The client and server exchange "requests" and "responses," and the rules governing that exchange are the "protocol (HTTP)." The "domain" points to where to access, "cookies" and "sessions" work together to keep you logged in, and "caching" speeds up how quickly pages load.

You can dig deeper into each of these mechanisms in the dedicated topics below.

Related topics:

🏠 Back to top