The Building Blocks of the Web
The web runs on a simple client–server model.
- Client: Usually your browser or mobile app that requests data.
- Server: The machine that stores and serves the website’s content.
When you type https://example.com, your browser (the client) sends a request to the server, and the server sends back a response usually an HTML document that your browser renders as a web page.
π Think of it like ordering food at a restaurant:
You (the client) place an order (request), the kitchen (server) prepares your food (data), and the waiter brings it back to you (response).
Now, what exactly makes up that webpage you see? It’s a combination of three core technologies:
- HTML (HyperText Markup Language): the structure of the page — headings, paragraphs, images, buttons.
- CSS (Cascading Style Sheets): the style — colors, fonts, layout, and design.
- JavaScript (JS): the brain — adds interactivity, logic, and dynamic behavior (like form validation, pop-ups, or API calls).
Together, these three are the building blocks of every web application.
When combined with a backend language (like Python, Node.js, or PHP) and a database, they create the full dynamic experience we call a web application.
User Agents
A User Agent (UA) is simply the identity of your browser or app when it communicates with a server.
It tells the server things like:
- Which browser you’re using (Chrome, Firefox, Safari)
- Which device and OS you’re on (Windows, Android, iOS)
Example of a User Agent string:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/118.0.0.0 Safari/537.36
Why it matters:
- Servers may customize content for different devices.
- Attackers sometimes spoof user agents to disguise malicious bots, so it’s also a security signal for web applications to analyze.
HTTP Request–Response Cycle (The Core of Web Communication)
Every web interaction from loading a page to submitting a form happens through a quick exchange between your browser (client) and a web server.
This exchange follows the HTTP Request–Response cycle, the foundation of how the web works.
HTTP Request: How the Browser Asks for Data
A request is what your browser sends to the server. It includes what you want, where from, and sometimes extra data.
-
Request Line → Method + Path + Protocol
Example:GET /product?productID=3 HTTP/1.1- GET
→ Retrieve data
- POST
→ Send data
- PUT
/ DELETE → Update or remove data
- GET
→ Retrieve data
-
Headers → Extra info for the server. Some Common ones are:
- User-Agent → Browser info
- Cookie
→ Session data
- Accept
→ Response type browser expects
-
Body (Optional) → Data sent with
POST,PUT, etc.
Example:username=prachi&password=1234
HTTP Response: How the Server Replies
Once the server receives the request, it replies with a response containing a status, headers, and body.
Parts of Response:
-
Status Line → Shows if the request succeeded
- 200
Ok→ Success
- 404
Not Found→ Missing resource
- 500
Internal Server Error→ Server issue
- 200
Ok→ Success
-
Response Headers → Metadata about the response. Some common ones are:
- Content-Type: text/html
- Cache-Control: no-store
- Content-Security-Policy: default-src 'self'
-
Body → The actual content (HTML, JSON, image, etc.)
Cookies - Sweet but Risky!
HTTP, by design, is a stateless protocol, every request and response are independent. This means that once a server responds, it “forgets” everything about that client. It doesn’t remember who you are, whether you’re logged in, or what’s in your shopping cart.
That’s where cookies come in. Cookies allow websites to store small pieces of data on the user’s browser to maintain state across multiple requests. This helps servers “remember” users between visits or page loads.
For example, when you log into a website, the server sends back a cookie like this:
Your browser stores it and automatically sends it with every future request to the same site:
Now, the server knows who you are and can load your personalized dashboard or saved settings.
Common Uses of Cookies
- Session management: Remembering users after login
- Personalization: Storing theme or language preferences
- Tracking: Analyzing user behavior or ad performance
TLS (Transport Layer Security)
TLS is what puts the S in HTTPS. It encrypts the data exchanged between your browser and the server.
Without TLS, anyone on the network could eavesdrop on your traffic (like reading your messages in a coffee shop’s Wi-Fi).
TLS ensures:
- Confidentiality: Data is encrypted.
- Integrity: Data isn’t modified in transit.
- Authentication: You’re talking to the real website, not an imposter.
Same Origin Policy (SOP) — The Silent Guardian
The Same-Origin Policy (SOP) is a browser security rule designed to protect users and their data. It prevents one website from accessing or modifying the data of another unless both share the same “origin.”
In simple terms, it stops malicious websites from snooping on or manipulating data belonging to another site you’re logged into like your email or bank account.
What is an "Origin"?
An origin is made up of three parts:
-
Protocol – The communication method used (e.g.,
httporhttps) -
Domain (Host) – The website’s name or address (e.g.,
example.com) -
Port – The network channel used by the server to send and receive data (default is 80 for HTTP and 443 for HTTPS)
Example: https://example.com:443
Why SOP is important?
Since HTTP is a stateless protocol, the browser has no memory of previous interactions. Every request and response are treated independently.
To maintain user sessions (like staying logged in), websites rely on cookies.
Without SOP, any malicious site could use your active cookies to steal data from another website (for example, sending requests to your bank account while you’re logged in).
The Same-Origin Policy prevents such attacks by allowing a page to access data only from the same origin.
This means that a script loaded from https://evil.com cannot read cookies, responses, or DOM content from https://bank.com.
Wrapping Up
So that’s a quick tour of how the web really works under the hood from the building blocks of a web page to how requests and responses flow between your browser and a server. We also touched on some key security concepts that make modern web apps safe and functional.
If you’ve followed along this far, you now know how HTML, CSS, and JavaScript come together, how browsers identify themselves as user agents and how data travels across the web. Pretty cool, right?
But we’ve only scratched the surface! π
In the next post, we’ll dig deeper into the security side of things exploring:
πͺ Cookies and how they help maintain sessions in a stateless world
π TLS, the magic behind HTTPS and secure communication
π¬ Response headers that quietly protect users behind the scenes
π§ Same-Origin Policy (SOP) and how it keeps websites isolated
π And finally, CORS, the modern way to safely share data across origins
These concepts are essential whether you’re a developer, tester or ethical hacker, and understanding them will give you a huge head start in securing applications.
Stay tuned. We’ll make these technical topics easy, visual, and fun to learn!



Insightful content.
ReplyDeleteGlad you found it insightful. Do check out the other posts also.
Delete