The web, HTTP and your development environment
Every front-end developer spends the working day inside one conversation: a browser asking a server for something, and the server answering. When a page is slow, broken or insecure, the cause is almost always visible in that conversation, if you know how to read it. This module teaches you to read it fluently. You take a web address apart, follow a request from a domain name to a server and back, read the raw messages the two exchange, and see how websites remember who you are. Then you set up the tools you will use for the rest of the course: the browser's Network panel, the terminal, curl and Visual Studio Code.
If you did Web Development for Beginners: HTML and CSS (WEB-101), the first sections will feel familiar for a few paragraphs. Keep going: this module goes much further, and every later module depends on it.
The project for this course
From this module to Module 10 you build one application, the Walk Planner, for Mandla's Mountain Walks. The company is invented for the course: Mandla Dube runs small guided walks on Table Mountain, Lion's Head, Silvermine and Cape Point in Cape Town. His visitors want to see the walks, compare how hard they are, check the weather for the day, see prices in their own currency and send a booking enquiry. Each module adds a layer. This week you set up the project folder and the tools, and investigate how real sites like the one you will build actually behave.
The invented address www.mandlaswalks.co.za appears in the examples. It does not exist, which is useful in itself, as you will see when you look it up.
Taking a URL apart
A URL (Uniform Resource Locator) tells the browser three things: how to ask, whom to ask and what to ask for. Here is a long one, with every part a URL can have:
https://mandlaswalks.co.za:443/walks/lions-head?date=2026-12-05&group=4#prices
| Part | In the example | What it does |
|---|---|---|
| Scheme | https | The protocol to use. https is HTTP over an encrypted connection. |
| Host | mandlaswalks.co.za | The name of the server. DNS turns it into an IP address. Many sites also answer to a www. version of the name. |
| Port | 443 | Which "door" on the server to knock on. Left out, it defaults to 443 for https and 80 for http, which is why you rarely see it. |
| Path | /walks/lions-head | Which resource on that server. It looks like a folder path, but the server decides what it means. |
| Query string | ?date=2026-12-05&group=4 | Extra information as name and value pairs, joined by &. Here: the walk date and the size of the group. |
| Fragment | #prices | A place inside the page. The browser keeps it to itself: it is never sent to the server. |
Some characters cannot appear in a URL as they are, because they have a meaning there or are not plain ASCII. They are percent-encoded: a space becomes %20, and "Silvermine & Cape Point" in a query string becomes Silvermine%20%26%20Cape%20Point. Browsers do this for you in the address bar. When your own JavaScript builds a URL, in Module 8, you will use tools that do it for you too.
Try it: watch the fragment stay at home
Open any long article on Wikipedia, click an entry in its contents list, and look at the address bar: a fragment such as #History appears and the page jumps. Open the Network panel (press F12, then choose Network), and click another contents entry. No new request appears, because the fragment is handled entirely by the browser.
From a name to a server: DNS
Computers on the internet find each other by IP address: four numbers such as 196.25.1.200 for the older IPv4, or a longer address such as 2001:db8::25 for IPv6. People use names. The Domain Name System (DNS) is the internet's directory that turns one into the other.
When you type a host name, your computer asks a resolver, usually run by your internet provider or a public service. If the resolver does not already know the answer, it works down the tree of names: it asks a root server who handles .za, asks that server who handles .co.za, and asks that server who handles mandlaswalks.co.za. The last one, the domain's authoritative name server, gives the answer. Every answer comes with a time to live (TTL), the number of seconds it may be kept, so most lookups are answered from a cache in a few milliseconds.
- A record
- Maps a name to an IPv4 address.
- AAAA record
- Maps a name to an IPv6 address.
- CNAME record
- Says a name is another name for something else, such as
wwwbeing another name for the hosting company's server. - MX record
- Names the servers that receive email for the domain. Not used by browsers, but it explains why a site's email can work while its website is down.
Two consequences matter to a front-end developer. First, when a site moves to a new server, some visitors keep reaching the old one until the cached answer's TTL runs out. Second, "the site cannot be reached" with no status code means the browser never got as far as a server: DNS failed, or the connection did. A status code such as 404 means a server did answer.
Try it: look up a name yourself
Open a terminal (the section on the terminal below shows how) and type nslookup www.gov.za. You see the resolver's address, then the answer: one or more IP addresses, sometimes after a CNAME. Now try nslookup www.mandlaswalks.co.za. The answer is that the name does not exist, usually shown as "NXDOMAIN" or "can't find". That is exactly what the browser would be told, which is why it shows its own error page instead of a status code.
The HTTP conversation
Once connected, browser and server talk HTTP (Hypertext Transfer Protocol). The browser sends a request and the server sends back a response. Each is a plain, readable message with three parts: a first line, a set of headers, and an optional body. Today most sites use HTTP/2 or HTTP/3, which send the same information in a compressed binary form, but developer tools and curl show it to you in the readable HTTP/1.1 layout, and the meaning is the same.
GET /walks/lions-head?date=2026-12-05 HTTP/1.1
Host: www.mandlaswalks.co.za
User-Agent: Mozilla/5.0 (X11; Linux x86_64) Firefox/144.0
Accept: text/html
Accept-Language: en-ZA,en;q=0.8
Cookie: session=7f3c9a
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 18342
Cache-Control: max-age=300
Set-Cookie: seen_banner=yes; Path=/; Max-Age=2592000
<!doctype html>
<html lang="en-ZA">
...
The request's first line holds the method (GET), the path with its query string, and the protocol version. The response's first line holds the version, the status code (200) and a short reason phrase. A blank line separates the headers from the body. A GET request has no body. The response's body here is the HTML of the page.
Methods
The method says what the client wants done with the resource. Two properties matter. A safe method only reads, so a browser or a search engine may send it freely. An idempotent method has the same effect whether it is sent once or five times, so it can be retried safely after a dropped connection.
| Method | Used to | Safe | Idempotent |
|---|---|---|---|
GET | Fetch a resource: a page, an image, data | Yes | Yes |
HEAD | Fetch only the headers, to check a resource | Yes | Yes |
POST | Send data for the server to act on: a form, a new booking | No | No |
PUT | Replace a resource with the one sent | No | Yes |
PATCH | Change part of a resource | No | Not necessarily |
DELETE | Remove a resource | No | Yes |
OPTIONS | Ask what the server allows, used by browsers in CORS checks (Module 9) | Yes | Yes |
This is why a browser asks "Confirm form resubmission?" when you reload a page that came from a POST: sending a booking twice might make two bookings. A GET request should never change anything. A link that deletes a record when it is followed is a bug waiting for a search engine to find it.
Status codes
The status code's first digit gives its class, so you can read the meaning of a code you have never seen.
| Code | Meaning | When you see it |
|---|---|---|
| 1xx | Information | Rarely, inside the protocol |
| 200 OK | Success | The normal answer |
| 201 Created | Success, something was created | After a POST that made a new record |
| 204 No Content | Success, nothing to send back | After a DELETE |
| 301 Moved Permanently | Redirect, for good | http to https, or an old address to a new one. The Location header says where. |
| 302 Found | Redirect, for now | After logging in |
| 304 Not Modified | Your cached copy is still good | Reloading a page whose files have not changed |
| 400 Bad Request | The request makes no sense | Malformed data sent to an API |
| 401 Unauthorized | Not logged in, or the token is missing or wrong | Calling an API without a key |
| 403 Forbidden | Logged in, but not allowed | Opening someone else's account page |
| 404 Not Found | Nothing at that path | A broken link, or a file name with the wrong capital letter |
| 405 Method Not Allowed | That method is not accepted here | A GET to an address that only takes POST |
| 429 Too Many Requests | Slow down | Calling an API too often (Module 9) |
| 500 Internal Server Error | The server's code failed | A bug on the back end |
| 502 Bad Gateway, 503 Service Unavailable | A server in front could not reach the real one, or it is overloaded or down for maintenance | During an outage |
The rule of thumb: 4xx means the request was wrong, so look at what the browser sent, and 5xx means the server failed, so the front end alone cannot fix it.
Headers
Headers carry everything about the message that is not the message itself. Their names are not case-sensitive, and HTTP/2 shows them in lower case.
| Header | Sent in | What it says |
|---|---|---|
Host | Request | Which site on the server is wanted. One server often hosts hundreds of sites. |
User-Agent | Request | Which browser and system is asking |
Accept, Accept-Language | Request | Which formats and languages the browser prefers |
Cookie | Request | The cookies the browser holds for this site |
Authorization | Request | A key or token proving who is asking (Module 9) |
Content-Type | Both | What the body is: text/html, text/css, application/json |
Cache-Control | Response | How long the browser may keep and reuse the file |
ETag, Last-Modified | Response | A version label, so the browser can ask "has this changed?" and get a 304 |
Location | Response | Where a redirect goes |
Set-Cookie | Response | A cookie the browser should store |
Query strings and bodies
There are two places to send data with a request. A query string is part of the URL, so it appears in the address bar, in the history, in bookmarks and in server logs. That suits filters and searches, such as ?difficulty=easy&sort=price, because a visitor can bookmark or share the result. A body travels inside the request, after the headers, and suits data that changes something or is private, such as a booking form's contents or a password. That is why forms that change things use POST, and why you never put a password in a URL.
Remembering you: cookies and sessions
HTTP is stateless: every request stands alone, and the server has no built-in memory of the last one. Yet sites remember that you are logged in and what is in your basket. They do it with cookies.
A cookie is a small named value that a server asks the browser to keep, with a Set-Cookie header. From then on, the browser sends it back with every request to that site, in the Cookie header. The usual pattern for logging in is a session:
- You send your email address and password with a POST request.
- The server checks them, creates a session record on the server, and gives it a long random identifier.
- The response sets a cookie holding only that identifier, such as
session=7f3c9a. - Every later request carries the cookie. The server looks up the session and knows who you are.
- Logging out deletes the session on the server, so the identifier is worthless even if someone copied it.
A cookie's attributes control how carefully the browser treats it. Secure means it is only ever sent over HTTPS. HttpOnly means JavaScript in the page cannot read it, so a malicious script injected into the page cannot steal the session. SameSite=Lax or Strict stops the browser sending it with requests started by other sites, which blocks a class of attack called cross-site request forgery. Max-Age or Expires says how long it lives. Without either, it disappears when the browser closes.
You will not build a login in this course: that is back-end work for Part 2. But you will meet cookies in every site you inspect, and in Module 8 you will store data in the browser in a different way, with localStorage, which is never sent to the server at all.
The Network panel in depth
Every browser's developer tools have a Network panel that records each request a page makes. Open the developer tools with F12 or Ctrl+Shift+I in Chrome, Edge or Firefox, on Windows or Linux Mint, and choose Network. In Firefox, Ctrl+Shift+E opens it directly. It only records while it is open, so reload the page after opening it.
| Column or control | What it tells you |
|---|---|
| Name, Status, Type | Each file, its status code, and what kind of file it is |
| Size (Chrome) or Transferred (Firefox) | How many bytes crossed the network. "memory cache" or "disk cache", or "cached" in Firefox, means it came from the browser's own copy. |
| Time and Waterfall | How long each request took, and when it started relative to the others |
| Filter buttons (All, Doc, CSS, JS, Img, Fetch/XHR) | Show one kind of request. Fetch/XHR shows the data requests made by scripts. |
| Preserve log (Chrome) or Persist Logs (Firefox) | Keep the list when the page navigates or redirects, so you can see what happened before |
| Disable cache | Fetch everything fresh while the tools are open, to see what a first-time visitor experiences |
| Throttling | Simulate a slow connection, such as "Slow 4G" or "3G" |
Click any request to see its details. The Headers tab shows the request and response headers, the Payload tab (Chrome) or Request tab (Firefox) shows a query string or body, Preview and Response show what came back, and Timing breaks the time into stages: waiting in a queue, the DNS lookup, connecting, setting up TLS, waiting for the server's first byte, and downloading. A long wait for the first byte points at a slow server. A long download points at a large file.
Right-click a request and choose Copy, then Copy as cURL (Chrome) or Copy as cURL (POSIX) (Firefox), and you get a terminal command that repeats the request exactly, which you can run with curl.
Worked example: why is the walks page slow on a phone?
Mandla says a friend's prototype of his walks page "takes forever" on his phone. You open it in Chrome with the Network panel open, tick Disable cache, set throttling to Slow 4G and reload.
- The bottom bar says 38 requests, 9.4 MB transferred, finished in 41 seconds.
- You click the Size column to sort by size. The top three are photographs:
table-mountain.jpgat 4.1 MB,lions-head.jpgat 2.8 MB andsilvermine.jpgat 1.9 MB. - Clicking
table-mountain.jpg, Preview shows it is 6,000 pixels wide, although the page shows it about 800 pixels wide. - Timing shows the server answered in under 100 milliseconds: the time is all download.
The diagnosis: the server is fine, the images are about ten times larger than they need to be. Resized to 1,600 pixels wide and recompressed, the three photos come to under 900 KB together, and the page finishes in about 5 seconds on the same throttled connection. Module 2 shows how to serve each screen an image of the right size.
The terminal
Professional front-end work happens partly in a terminal: a window where you type commands instead of clicking. Package tools, local web servers, test runners and Git are all used this way, and many tools have no other way in. You need only a handful of commands to start.
Opening one. On Windows 10 or 11, open Windows Terminal or PowerShell from the Start menu. On Linux Mint, open Terminal from the menu, or press Ctrl+Alt+T. VS Code also has one built in: Terminal, then New Terminal, or Ctrl+`. It opens in your project's folder, which is usually what you want.
The terminal shows a prompt, which includes the folder you are in, the working directory. Every command acts there unless you say otherwise.
| To | Linux Mint | Windows PowerShell |
|---|---|---|
| Show where you are | pwd | pwd |
| List the files here | ls, or ls -la to include hidden files | ls or dir, and ls -Force to include hidden files |
| Go into a folder | cd walk-planner | cd walk-planner |
| Go up one folder | cd .. | cd .. |
| Go to your home folder | cd ~ | cd ~ |
| Make a folder | mkdir css | mkdir css |
| Make an empty file | touch index.html | New-Item index.html |
| Open the folder in VS Code | code . | code . |
| Clear the screen | clear, or Ctrl+L | clear or cls |
Two habits save hours. Press Tab to complete a file or folder name after typing its first letters, which also stops spelling mistakes. Press the up arrow to bring back earlier commands.
Paths
A path says where a file is. An absolute path starts from the top of the file system: /home/lerato/projects/walk-planner/index.html on Linux Mint, or C:\Users\Lerato\projects\walk-planner\index.html on Windows. A relative path starts from where you are: from inside walk-planner, the same file is simply index.html, and the stylesheet is css/styles.css. Two dots, .., mean "the folder above", and one dot, ., means "this folder".
Three differences between the systems catch people out:
- Slashes. Windows writes paths with backslashes,
css\styles.css, and Linux with forward slashes,css/styles.css. PowerShell accepts both. Web addresses and the paths in your HTML and CSS always use forward slashes, on every system. - Capitals. Linux file names are case-sensitive, so
Photo.jpgandphoto.jpgare two different files. Windows treats them as the same. Most web servers run Linux, so a link that works on your Windows laptop can give a 404 once published. Use lower case for every file and folder name. - Hidden files. On Linux, a name starting with a full stop, such as
.gitignore, is hidden from a plainls. You will create several such files in this course.
Avoid spaces in project file and folder names too: walk-planner, never Walk Planner. Spaces must be quoted in the terminal and become %20 in URLs.
curl: HTTP from the terminal
curl sends HTTP requests from the terminal and shows you exactly what comes back, with no browser in between. It is installed on Windows 10 and 11 and usually on Linux Mint (if not, sudo apt install curl).
# Only the response headers (a HEAD request)
$ curl -I https://www.gov.za/
# The response headers and the body
$ curl -i https://example.com/
# Follow redirects, showing each response's headers
$ curl -IL http://www.gov.za/
# Everything: the connection, the request sent and the response
$ curl -v https://example.com/ -o page.html
# Send a POST with form data to a test service that echoes it back
$ curl -X POST -d "walk=lions-head&group=4" https://httpbin.org/post
In curl -v output, lines starting with > are what curl sent and lines starting with < are what came back, with the rest describing the DNS lookup, connection and TLS. The -o page.html saves the body to a file instead of filling the screen. example.com is a domain reserved for examples, and httpbin.org is a public testing service that replies with whatever you sent it.
Try it: follow a redirect chain
Run curl -IL http://www.gov.za/ (on Windows, curl.exe -IL http://www.gov.za/). Read each block of headers in turn: the first response is a redirect, 301 or 302, with a Location header pointing at the https address, and the last is 200. Count the redirects. Each one costs the visitor a round trip before the page can start loading.
Visual Studio Code for professional work
If you did WEB-101 you have VS Code already. If not, download it free from code.visualstudio.com. On Linux Mint, choose the .deb download and open it, or install "Visual Studio Code" from the Software Manager. Now set it up the way you will use it for the rest of the course.
- Work in a folder. Always open the project folder (File, Open Folder, or
code .in the terminal), never single files. The Explorer, search, terminal and later Git all work on the folder. - Format on save. Open Settings with Ctrl+,, search for "format on save" and tick it. VS Code's built-in formatters then tidy your HTML, CSS and JavaScript every time you save, so your indentation is always consistent.
- Auto save. Search for "auto save" and choose
onFocusChange, so a file saves when you switch to the browser. - The Command Palette. Ctrl+Shift+P opens a search box for every command VS Code has. When you do not know where something is, type what you want there.
- Find across files. Ctrl+Shift+F searches the whole project, for example for every place a class name is used.
- Several cursors. Hold Alt and click to place extra cursors, or select a word and press Ctrl+D to select its next occurrence. Typing then changes all of them at once.
- Emmet. In an HTML file, type
ul>li*4and press Tab: VS Code writes a list with four items. Type!and Tab in an empty HTML file for a complete page skeleton.
Leave extensions for now. Each later module names the one or two it needs, such as Live Server, a local web server, which Module 2 introduces.
Git. Module 10 uses Git from the terminal, and you will commit your work from this module onwards. Check whether it is installed with git --version. If it is not, install it from git-scm.com on Windows, accepting the defaults but choosing VS Code as Git's default editor, or with sudo apt install git on Linux Mint. Then tell Git who you are, once:
$ git config --global user.name "Lerato Mokoena"
$ git config --global user.email "your-github-noreply-address"
$ git config --global init.defaultBranch main
Use the private "noreply" address shown in your GitHub settings under Emails, because commit details are public in a public repository.
Setting up the Walk Planner folder
Create the project from the terminal, so the commands become familiar. This is the structure you will grow over the course:
walk-planner/
index.html the walks page
css/ stylesheets
js/ scripts, from Module 6
images/ photographs and icons
data/ the walks as JSON, from Module 9
notes/ your notes and investigation records
$ mkdir -p ~/projects/walk-planner
$ cd ~/projects/walk-planner
$ mkdir css js images data notes
$ touch index.html css/styles.css notes/module-1.md
$ code .
On Windows PowerShell, the same steps are mkdir ~\projects\walk-planner, cd ~\projects\walk-planner, mkdir css, js, images, data, notes (PowerShell takes a list, separated by commas), New-Item index.html, css\styles.css, notes\module-1.md and code ..
The .md file is for your notes, written in Markdown, which you met in WEB-101 if you took it: # starts a heading and - starts a list item. VS Code shows a formatted preview with Ctrl+Shift+V. Keeping your investigation notes in the project means they travel with it and, from Module 10, go into its history.
Sources
- RFC 9110, "HTTP Semantics" (June 2022): https://www.rfc-editor.org/rfc/rfc9110
- MDN Web Docs, "An overview of HTTP": https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Overview
- MDN Web Docs, "HTTP response status codes": https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status
- MDN Web Docs, "Using HTTP cookies": https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies
- Chrome for Developers, "Network features reference": https://developer.chrome.com/docs/devtools/network/reference
- curl, "curl man page": https://curl.se/docs/manpage.html
- Visual Studio Code documentation, "Basic editing": https://code.visualstudio.com/docs/editing/codebasics