ContentsClose contents
Pre-release
Chapter 3 · How the web worksCHAPTER 03

Six-part pre-release for review, with 12 figures, four tables, and worked exercises. The application journeys are proposed; no Django application is implemented.

Working towards: Plan ready (Chapter 5). A product brief, written requirements, web vocabulary, a checked Python setup, and a proposed architecture. Django is not installed yet. All milestones

CHAPTER THREE

How the web works

Stage 1: Requirements and first project (Chapters 1 to 8)

Prerequisites: Chapters 1 and 2: Otahque’s people, needs, and product rules

What you’ll build: a reasoned walkthrough of an Otahque journey from browser to server and back, and your own observation of real exchanges in a browser’s developer tools.

Why This Matters

Every requirement in Chapter 2 has to survive a trip across a network. Soni reads an event page, Sai registers, and Raj cancels, and each of those actions is a message from a browser that the server may accept, refuse, or never receive. If we do not know what travels in those messages, we cannot say where a rule must be checked or what Sai should see when her connection drops halfway.

This chapter builds that picture without any code. It names the parts of a web address, follows a page visit as separate requests and responses, separates reading information from requesting a change, and draws the line between what a browser may do for convenience and what only the server can decide. It ends with a complete registration journey, including the case where the outcome is unknown.

Nothing here is Django yet. But every later chapter assumes this vocabulary: a URL configuration matches the path you meet here, a view answers the request, and a redirect after a form is the pattern you trace in this chapter.

By the end of the chapter, you will be able to:

  • explain the roles of a browser and a web server;
  • identify the main parts of a web address and explain how a browser reaches a site;
  • distinguish asking to read information from requesting a change;
  • describe which work belongs in the browser and which belongs on the server;
  • trace an Otahque journey through requests, decisions, and responses.

You will produce an annotated walkthrough of an event visit and a registration request. You need Chapters 1 and 2 and familiarity with opening a page in a browser. This chapter explains the intended application; our first local development page comes in Chapter 6, and our first Otahque page in Chapter 9.

PAGE 001

What You Need to Know

Browsers, servers, and an event page

Soni wants to decide whether a community event is suitable for her. In our proposed Otahque application, she follows a link to its published event page. The page should show the information she needs to make that decision. What has to happen between following the link and reading the result?

Begin with the browser

A browser is an application that lets a person open and interact with web pages. Edge, Firefox, Chrome, and Safari are examples. Soni uses her browser to follow the event link; the browser does the communication needed to obtain the page.

The internet is the network infrastructure connecting devices and networks around the world. The web is one system that uses that infrastructure to make pages and other resources available through addresses and links. A resource is something a browser can ask for, such as an event page or an image. Other systems, including email, also use the internet.

A browser and a search engine have different jobs. A search engine helps find pages; a browser displays and lets us use them. Soni can follow an event link someone sent her without first searching for the event.

One website, several pages

Suppose Soni starts at an Otahque page listing upcoming events. She notices a Python workshop and follows its title. The browser now displays the detail page for that workshop. These are two pages within the same website: one helps her choose an event; the other helps her examine that choice.

A web page is a document the browser can display. Its content and structure are described using Hypertext Markup Language, shortened to HTML. Structure means such things as which text is a heading, which items form a list, and which words are links. We will write HTML later; for now, recognize that the browser receives a description of the page rather than a photograph of someone else’s screen.

A website groups related pages and resources. Otahque’s event list, individual event details, and account pages will belong to one site. Soni can move between those pages while continuing to use the same browser application. Figure 3.1 shows this distinction using a proposed reading journey.

An Otahque website boundary contains an event-list page and a workshop-detail page. An arrow from the Python workshop link to its detail page shows Soni navigating between pages using the same browser.
Figure 3.1 — Two pages within the proposed Otahque website.

Read the arrow as “follow this link”, not “move the entire website”. The detail page is about the selected event. The browser is the tool displaying it. The surrounding boundary groups pages that belong together; it does not represent the physical size of a server.

Que. 1 Soni follows the Python workshop link. Has she opened a different browser, a different page, or necessarily a different website?

Flip to check your answerFold answer back

Answer. She has opened a different page. In this example, both pages belong to Otahque, and she is still using the same browser. A link can also lead to another website, but that is not what the illustrated link does.

Meet the other side: the web server

The browser needs another program to receive its request and return information. Software doing that job is called a web server. People also use “server” for the computer running that software. In this chapter, focus on the job: receiving a request, handling it, and sending a response.

The browser acts as a client: software asking a service for something. A request is the message it sends. A response is the message sent back. Soni is the person using the client; she does not need to construct these messages herself.

These are software roles, not two special types of computer. Later, your own computer will run both a browser and a development server. A public site may use several machines behind the service a visitor reaches. We can understand the basic exchange before deciding how Otahque will be hosted.

Que. 2 If Soni opens the same event on her phone instead of her laptop, which role does the phone’s browser perform?

Flip to check your answerFold answer back

Answer. It is still the client. The device has changed, but the browser still asks the website for information and displays the result. Client and server describe jobs in the exchange.

New Concept: HTTP

What problem exists? A browser and a server, written by different people, have to understand each other’s messages.

What did people do before? Before a shared format existed, each client and server needed their own agreement about how to interpret each message.

What is HTTP? The Hypertext Transfer Protocol: the agreed rules for web messages. A client sends a request with a method, an address, headers, and sometimes a body; the server returns a response with a status code, headers, and usually a body. HTTPS is the same protocol protected by TLS.

Why it matters to us? Django receives HTTP requests and returns HTTP responses, so every view we write answers one of these messages.

Now let’s follow one.

Follow one successful page visit

First, Soni follows the event link. Her browser sends a request asking for that page. Next, the server handles the request and returns a response containing page content. Finally, the browser interprets that content and displays a page she can read. Figure 3.2 separates the outgoing request from the returning response.

Soni uses her browser on the left. An upper arrow carries a request for an event page to web server software on the right; a lower arrow returns page content to the browser, which displays it.
Figure 3.2 — The browser asks for an event page and receives a response.

This is a simplified successful exchange. A real page may need further requests for images and other supporting files. The diagram leaves out the intermediate network machinery so we can follow the two roles. The next topic explains how an address helps the browser reach the right site.

The response does not have to be a page already saved as a finished file. An application can assemble page content when a request arrives. For example, Otahque will need to present information about the particular published event Soni chose. We will examine that distinction in “What runs in the browser and on the server”; no application has been built at this point.

One page can need several exchanges

Imagine that the workshop page includes a photograph of the venue. The page document can identify where that photograph is available without containing the image itself. After reading the document, the browser can ask for the image in another request. The server then returns image data in another response.

In Figure 3.3, the messages are arranged over time. Start at the top and read downwards. The browser first obtains the document, discovers the image reference, and obtains the image. It combines the information into the page Soni sees. Each returning arrow answers a particular request.

Time runs down two columns for browser and server. The browser requests the event document and receives it, then requests the venue image and receives image data. The document and image are combined for display.
Figure 3.3 — A page document and its image can arrive in separate responses.

This is one possible loading sequence, with only two resources shown. Browsers can fetch several resources at once and can sometimes reuse copies they already have. The picture is not a promise that every page always makes two requests in exactly this order. Its purpose is to show why “open a page” can involve more than one exchange.

Now give the example a problem: Soni can read the workshop description, but the venue photograph does not appear. The visible description is useful evidence: at least some page content is available to her. It does not tell her whether the image is missing on the server, could not be reached, or failed to display. Those possibilities require further observation.

Que. 3 Does a missing venue photograph prove that the whole Otahque website is unavailable?

Flip to check your answerFold answer back

Answer. No. The document and photograph are separate resources in this example. Soni can report that the description is visible while the photograph is missing. That precise observation is more useful than claiming the whole site is down; the cause is still unknown.

In practice: reporting a partially loaded page

Situation. An event page shows its description, but the venue photograph is missing.

Application. Report which content is visible and which resource is absent. Thinking in separate request-and-response exchanges helps a developer narrow the investigation.

Consideration. The observation does not establish the cause. Avoid reporting that the entire service is down when only one part has been checked.

Try it yourself: explain a partial page

Use Figure 3.3 on paper. Cover the final response arrow with your hand. Assume the event document has arrived but the image data has not. Name one thing Soni may still be able to read and one thing she cannot yet see. Then write a short problem report that states the observation without guessing its cause. No browser changes, commands, or project files are needed.

Que. 4 What would a useful explanation and problem report say?

Flip to check your answerFold answer back

Answer. Soni may be able to read the workshop description contained in the document, but she cannot yet see the venue photograph. A useful report is: “The workshop description is visible, but the venue photograph is missing.” It identifies the affected part of the page without claiming that the server, network, or browser is definitely responsible.

Reading an event is different from registering

Chapter 2 separated browsing from registration. That distinction still matters here. Opening the event page asks to read about the event. Under our proposed requirements, it does not reserve a place for Soni.

If Soni later chooses to register, the application must handle a separate request for that action and check the relevant rules. A page that looks encouraging is not, by itself, evidence that a registration was recorded. When we implement registration, the confirmation must reflect the result of the server’s decision.

Que. 5 Soni can see the event description. Does this establish that she has a place at the event?

Flip to check your answerFold answer back

Answer. No. It establishes that the browser has displayed event information. Registering is a separate action with its own result. Reading the page must not silently create a registration.

Consider Sai checking a confirmation while Sam plans the event. Sai needs a result about her own place; Sam needs an authorized view of registrations for the event he manages. Both use browsers, but their questions and permitted information differ. The client/server vocabulary tells us where the messages go. Chapter 2’s requirements tell us what the application must decide before answering.

That distinction will guide our later tests. A page appearing on screen is one observation. The application recording the right registration, refusing a duplicate, and showing the result to the right person are additional behaviours to verify. For this section, practise describing the exchange without treating the visible page as proof of every underlying rule.

Try it yourself

On paper, draw two boxes for Sai’s browser and the web server. Sai wants to read a published event before deciding whether to attend. Add one arrow for the request and another for the response. Label what each arrow carries, then write one sentence describing what the browser does after receiving the response. You do not need to visit a site or install anything.

Que. 6 What should the drawing and final sentence show?

Flip to check your answerFold answer back

Answer. Draw the request arrow from Sai’s browser to the server and label it “Ask for the event page”. Draw the response arrow back to the browser and label it “Page content”. Write: “The browser interprets the returned content and displays the event information.” The arrows represent messages, not Sai travelling to the server. This drawing shows reading an event, not booking a place.

Finding and reaching a web address

Soni receives a link to a workshop. Before following it, she wants to know which site it opens and whether it points to the event she expects. Reading an address is useful to a visitor; later, it also helps a developer distinguish a wrong destination from a missing page.

Read the address in parts

A web address is a Uniform Resource Locator, or URL. Consider the fictional address below. It is an illustration to read on paper, not a working Otahque route or an instruction to visit a site.

https://otahque.example/events/42/?view=details#venue

The scheme, https, names the protocol: the agreed rules for the exchange. Here it is HTTPS, a protected form of the Hypertext Transfer Protocol, or HTTP; the end of this section explains what that protection covers. The host, otahque.example, names the destination. The path, /events/42/, identifies a resource at that host. The query, view=details, supplies an extra value after the question mark. The fragment, venue, follows the hash sign and can identify a position within the returned page. Query and fragment are optional.

The fictional address https://otahque.example/events/42/?view=details#venue appears on one line. Brackets under its parts lead to five labels: scheme https is the protocol, host otahque.example is the site, path /events/42/ is the resource, query view=details is an extra value, and fragment venue is part of the page. A note says the browser keeps the fragment and does not send it in the HTTP request.
Figure 3.4 — Each part of an address has a different job.

For this example, the site would decide what event 42 and view=details mean. A readable path is not evidence that a matching file exists on disk. The server can use the path to choose application behaviour. The fragment is not sent in the HTTP request; the browser uses it after obtaining the resource.

Que. 7 If Soni changes only #venue to #schedule, is she asking for a different host?

Flip to check your answerFold answer back

Answer. No. The host has not changed, so the browser is still dealing with the same site. The fragment points within the resource and is handled by the browser. Whether the page contains a matching location is a separate question.

Find the host before asking for its page

Computers use network addresses to communicate. An Internet Protocol address, shortened to IP address, is one kind of address used to reach a network destination. A memorable host name and an IP address are different things. The Domain Name System, or DNS, provides name lookups that can supply addresses associated with a host.

In a simplified fresh visit, the browser and operating system obtain an address for the host, establish the required connection, and then ask the web service for a resource. A DNS lookup does not return the event description and does not decide whether Soni may register. Those are later jobs.

A browser first asks a DNS lookup service for an address associated with the host and receives an address. It then connects to the web service and requests the event path. The DNS branch never handles the event page or registration decision.
Figure 3.5 — Finding a host and requesting an event are separate exchanges.

The lookup step may use a previously saved result. A host can also have more than one address, so the diagram is not a claim that each visit performs a new lookup or always reaches the same machine. The useful distinction is between finding where to connect and asking the connected service what to return.

Que. 8 The host lookup fails before an event request can be made. Should Soni conclude that the workshop has been deleted?

Flip to check your answerFold answer back

Answer. No. The failure concerns reaching the named host. It says nothing about whether the workshop exists. First check the spelling of the host and whether other sites can be reached; do not change or delete event data to solve a connection problem.

What HTTPS protects

HTTP defines how web requests and responses are written and exchanged. HTTPS uses Transport Layer Security, or TLS, to encrypt communication between the client and server. Encryption makes the transmitted content unreadable to someone who merely observes that protected connection.

This protection matters when Sai later signs in. It does not decide whether Sai owns a registration, whether a place remains, or whether the displayed event details are truthful. Those questions belong to the application and its people. A protected connection to the wrong site is still the wrong destination, so Soni must read the host as well as the scheme.

Que. 9 Does HTTPS allow Raj to cancel another member’s place?

Flip to check your answerFold answer back

Answer. No. HTTPS protects the exchange in transit. Otahque must still identify Raj and enforce the rule that he can cancel only his own registration. Transport protection and permission checks solve different problems.

In practice: investigating a broken event link

Situation. A shared event link fails, although another page on the same website opens.

Application. Compare the host and path with the intended address before changing application settings. Distinguishing the site address from the requested page makes the report more precise.

Consideration. Do not paste private query values into a public issue. An address can contain information that was intended only for its recipient.

Try it yourself

On paper, annotate the fictional address above. Circle the host, underline the event path, and mark the optional query and fragment. Then describe which part changes if Soni opens event 43 on the same host. No site visit, installation, or file change is required.

Que. 10 What should the annotation and changed address show?

Flip to check your answerFold answer back

Answer. Circle otahque.example and underline /events/42/. Mark view=details as the query and venue as the fragment. For event 43 in this invented naming scheme, the path becomes /events/43/; the host stays the same. This shows a different resource on the same host, not a different DNS name.

Asking for information and requesting changes

Soni reads the workshop page. Sai, who already has an account in our proposed application, wants to register. Both actions involve messages, but they have different purposes. Reading should not silently consume a place. Registration asks the application to change its records.

A request has an action as well as an address

An HTTP method names the kind of action requested. GET asks for information about a resource. POST sends data for the server to process and is commonly used for actions that change application state. State means the information the application currently holds, such as which members have active registrations.

For Otahque, opening an event is a reading action. Submitting a registration is a request for a change. A form is a page element through which a person supplies information or submits an action. The browser translates its submission into a request; the application must decide whether to accept it.

Choosing POST does not make a request trustworthy, encrypt it, or prevent a second submission. HTTPS provides transport protection; application checks enforce the rules. Repeating a POST can have further effects unless the application handles repetition correctly. This is why Chapter 2’s duplicate-registration requirement must become a server-side check later.

Que. 11 Should following a link to read an event register the visitor as a side effect?

Flip to check your answerFold answer back

Answer. No. Reading the event is a GET-style action. Registration should require a deliberate request for the change. If simply reading a link took a place, a visitor could register unintentionally while exploring the site.

The message carries context and content

A request identifies a target and method, and can carry headers: named pieces of information about the message. It may also have a body containing submitted data. A response carries a status code, headers, and sometimes a body. For a successful event-page request, the body can contain HTML; for an image request, it can contain image data.

A header named Content-Type describes the format of a message’s body. For now, think of it as a label helping the recipient interpret what arrived. The body is the content itself. A header and body have different roles, just as a document’s format label differs from the document’s text. We will read actual request objects when we reach Django views.

Under the Hood: what the messages look like

Underneath the browser’s display, an HTTP request is a short block of text: a request line naming the method, the path, and the protocol version, then headers such as Host, then an optional body. The response starts with a status line, then its headers, a blank line, and the body. The listing below shows the shape of a request for an event page and of its response. Real messages carry more headers, and HTTP/2 and HTTP/3 send the same information in a binary form, but the parts are the same.

GET /events/42/ HTTP/1.1
Host: otahque.example
Accept: text/html

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8

<!DOCTYPE html> ... the event page ...

Read the response without over-interpreting it

A status code is a three-digit result attached to an HTTP response. Table 3.1 introduces a small useful set. These are general meanings, not final choices for every Otahque error or policy.

Table 3.1 — Selected HTTP response results
Code Meaning Example to reason about
200 Request succeeded. An event page was returned.
303 See another resource. After processing a form, direct the browser to a result page.
403 The server refuses the request. Access is not permitted.
404 The resource was not found, or its existence is not disclosed. An unknown event address.
500 An unexpected server condition prevented fulfilment. The server could not complete the request.

A browser connection error is different from receiving a 404 response. With a 404, a server has sent an HTTP response. A connection failure may prevent an HTTP response from arriving at all. Also, receiving 200 for a page does not prove that a registration was created: a page can successfully explain why an application action was refused.

Que. 12 Sai receives a page explaining that registration is closed. The page arrived successfully. Which result matters to her?

Flip to check your answerFold answer back

Answer. The application result: she does not have a newly confirmed place. Successful delivery of a page and successful registration are different observations. She should read the result message rather than infer a booking from the fact that a page appeared.

Common Error: a link that changes data

A plain link always makes a GET request, and browsers, link previews, and search crawlers may follow links on their own. A link that cancels a registration could therefore cancel it without anyone choosing to. Changes such as registering and cancelling belong in a form that sends POST, and the server must still check every rule when the form arrives.

A redirect asks the browser to make another request

A redirect is a response that points the browser towards another resource. One useful pattern after form processing is to return a 303 response with a Location header naming a result page. The browser then fetches that page with GET. In Figure 3.6, the result is a separate reading request after the submitted action.

A browser sends a registration POST. After processing it, the server returns a 303 response naming a result location. The browser follows that location with GET and receives a result page. The final reading step does not repeat the submitted action.
Figure 3.6 — Submitting an action and reading its result are separate requests.

Refreshing the resulting GET page normally reads it again rather than resubmitting the earlier form. This pattern helps the user experience, but it does not enforce the one-registration rule by itself. Sai could submit again from another tab, or a request could be repeated before the redirect arrives. The application still needs duplicate handling.

Que. 13 Does a redirect remove the need for a duplicate-registration check?

Flip to check your answerFold answer back

Answer. No. It separates form submission from the page subsequently displayed. It does not prevent every repeated submission. The server must still enforce the rule about one active registration per member and event.

In practice: reviewing a form submission

Situation. A registration form leads to a status page after submission, and the team wants to understand a reported duplicate.

Application. Separate the change request from the later page-reading request when describing the sequence. This helps reviewers ask which operation was repeated.

Consideration. A redirect can improve the navigation flow without enforcing uniqueness. Duplicate prevention remains an application responsibility.

Try it yourself

Classify these proposed Otahque actions on paper: Soni reads event details; Sai submits a registration; Raj submits a cancellation; Sam reads the list for an event he manages. For each, say whether it asks to read or requests a change, then name GET or POST as the method to consider. Do not perform these actions on a live site.

Que. 14 How should the four actions be classified?

Flip to check your answerFold answer back

Answer. Soni reads details: reading, GET. Sai registers: change request, POST. Raj cancels: change request, POST. Sam reads his event’s list: reading, GET. Reading can still require permission: GET does not mean that every visitor may see Sam’s list.

What runs in the browser and on the server

Sai sees an available place on an event page. While she reads, someone else may register. Which part of the system should decide whether her later request can succeed? To answer that, separate what her browser displays from what the shared application records.

Content, appearance, and interaction

HTML describes page content and structure. Cascading Style Sheets, or CSS, describe presentation such as spacing and colours. JavaScript is a programming language that can run in the browser to add behaviour. An event title can be HTML content, its visual spacing can be controlled by CSS, and a script can open or close an extra-details panel.

The three are not interchangeable. A title can remain meaningful when its styling is absent. Many links and forms work without custom JavaScript. Scripts can improve interaction, but the product should not depend on a decorative effect to communicate whether a registration succeeded. We will introduce each technology through a concrete need in later chapters.

Que. 15 A photograph loads and a button changes colour when Sai points at it. Does that show that registration works?

Flip to check your answerFold answer back

Answer. No. Those observations concern presentation and interaction in the browser. Registration also requires the application to check the request, record the correct result, and return an accurate confirmation.

The shared decision belongs on the server

The server side is where Otahque will apply the shared rules and work with stored records. A database is an organized store of data that software can read and update. We have not designed its tables yet. At this point, it is enough to know that a lasting registration needs to be recorded somewhere beyond one open browser tab.

The page might disable a registration button after the closing time. That can help the visitor, but it cannot be the only check. Browser content can be altered, an old page may still be open, and a request can come from software other than our page. The server must check the relevant rule when it processes the request.

On the browser side, Sai reads an available-place message and submits a request. Across the boundary, the application checks identity and current rules, records an accepted result, and returns a response. The browser display is distinct from shared stored records.
Figure 3.7 — Helpful browser feedback does not replace server decisions.

Suppose Sai’s page showed one remaining place, but another member took it before she submitted. The page was a view of information at an earlier time. The application must decide using current records and prevent conflicting requests from both taking the last place. Chapter 33 will address that concurrency problem; this chapter establishes why the decision cannot rely on the old page.

Que. 16 Sai edits the displayed number from zero places to ten on her own screen. What must happen if she then requests a place?

Flip to check your answerFold answer back

Answer. The server must use its own current records and rules. Editing a browser display must not create capacity or grant permission. The intended outcome comes from the application’s checks, not from a number supplied by the page.

Prefer checking rules in the browser?

Checking a form in the browser before it is sent, for example warning that an event looks full, gives quicker feedback and is worth having. It cannot replace the server’s check, because the person controlling the browser can change or skip it. We use browser checks for convenience and server checks for the rules, and we never treat the first as evidence of the second.

A page can be prepared in advance or assembled when requested

A static response can serve content prepared ahead of time. A dynamic response can be assembled for a particular request using current data. For example, the application could read Sai’s stored registrations and produce an HTML page listing them. The browser receives the resulting content; it never receives the database itself or the Python code used to produce the page.

Dynamic does not mean animated. A plain-looking page may be assembled from changing records, while a prebuilt page can contain an animation. Nor does a dynamic site have to regenerate every resource: its logo and styling can be served as ordinary files. The distinction concerns how content is prepared, not whether it looks lively.

Remembering a signed-in visitor across requests

HTTP is stateless: it does not by itself provide a continuous application memory of a visitor’s earlier requests. An application can add that continuity. A cookie is a small piece of data stored by a browser and sent with matching later requests according to its rules. A session is a way for the application to maintain context across requests.

One common arrangement gives the browser a session identifier in a cookie and keeps the related session information on the server. The identifier is a reference, not a copy of all the registration records. The server uses it to look up context, then applies permission checks. A session reference should be treated as sensitive; it is not something to paste into a problem report.

If Sai signs out, the application must stop treating subsequent requests as authorized through that sign-in. Closing a tab is not the same action as signing out. We will implement accounts in Chapter 27 and examine cookies and sessions in Chapter 28; the mechanism here is a conceptual preview, not a completed design.

Que. 17 Does recognizing Sai’s session mean she may see Sam’s organizer list?

Flip to check your answerFold answer back

Answer. No. Recognizing a signed-in member and authorizing access are separate decisions. The application must still check whether that member may view the requested event’s organizer information.

In practice: checking a disabled action

Situation. A page disables cancellation after a deadline, so a reviewer asks whether the rule is protected.

Application. Include a planned server-side check for the same forbidden action. The browser presentation and the operation accepting the request must agree.

Consideration. A disabled button alone is insufficient evidence. Test such cases in the authorized development environment, not by altering requests to a live service.

Try it yourself

Divide a sheet into Browser and Server. Place these tasks in the appropriate column: make an event heading blue; reject a duplicate registration; show or hide an explanation panel; decide whether Raj may cancel a particular registration; return a page showing the stored result. Explain why one task in the Server column cannot be entrusted only to a browser.

Que. 18 What is a model division of responsibility?

Flip to check your answerFold answer back

Answer. Browser: display the blue heading and show or hide the panel. Server: reject duplicates, check cancellation ownership, and return content based on stored results. For example, a duplicate check must work even if the browser sends a second request or its display has been changed. The browser then renders the returned result.

PAGE 002

How We Build It

Starting point: the vocabulary from What You Need to Know; no installation or code. You need a desktop web browser for Step 1 and paper for Step 2. The result is your own record of a real page exchange and a written trace of a registration journey with each of its outcomes.

The Custom Way: guessing from the screen

When a page looks wrong, the natural reaction is to judge from what the screen shows: the page is “broken”, the button “did nothing”, the registration “failed”. The screen shows only the end of a sequence of exchanges, and it can mislead. A page that looks complete may have one image request that failed; a page that looks unchanged may have been answered from the browser’s cache; a form that seems to have done nothing may have been accepted by the server while the reply was lost. Every browser keeps its own record of the exchanges it made, and Step 1 shows how to read it.

Step 1: Watch real exchanges in the browser’s developer tools

Open a desktop browser and visit https://example.com/, a page reserved for documentation examples. Then open the developer tools. In Chrome, Edge, and Firefox, press F12, or Ctrl+Shift+I on Windows and Linux, or Cmd+Option+I on macOS. In Safari, first turn on the developer features in Safari’s Advanced settings, then use the Develop menu. Select the Network panel, then reload the page so that the panel records the exchanges from the start.

Each row is one request and its response. Select the row for the page document itself, usually the first. Its details show the request method, GET, and the response status, 200. Then visit a larger site you trust and reload with the Network panel open. Record which requests actually appear, their types, and whether any came from the cache. You may see requests for stylesheets, scripts, or images, as in the example in Figure 3.3. Sites, browsers, and cache settings can produce different rows and timings.

Common Error: reading a cached page as a fresh answer

A browser may reuse a stored copy of a resource instead of asking again, and the Network panel marks such rows as coming from the cache. When you are checking whether a server’s answer has changed, look for a fresh request with its own status code, rather than trusting that the page on screen is new.

Que. 19 In the Network panel, the document row shows GET and 200, but one image row shows 404. What happened?

Flip to check your answerFold answer back

Answer. The browser’s request for the page document succeeded, and its separate request for one image found nothing at that address. The page and its image are different exchanges, so one can succeed while the other fails; the screen shows a page with a missing picture.

Step 2: Trace a complete Otahque journey on paper

We can now follow Sai from an event page to a registration result. This is a proposed interaction based on Chapter 2’s draft requirements, not evidence of working software. Assume she is signed in, the event is published, and the application will enforce the agreed rules. Exact addresses and response choices remain implementation decisions.

Follow the successful path

First, Sai opens the event address. The browser reaches the named host, using a DNS result where needed, and makes a protected request. The server returns content for the event. The browser displays it and obtains any additional resources it needs. Sai reads the details before choosing to register.

Next, her deliberate submission sends a change request. The application identifies her, checks access and the registration rules, and records an accepted registration. Only after the result is established should the response lead her to a confirmation that reflects that result. If the application uses the redirect pattern from “Asking for information and requesting changes”, the browser makes a separate reading request for the confirmation page.

Sai submits a request and the application checks the rules. If accepted, a registration is recorded and, when the reply arrives, she sees confirmation. If refused, nothing new is recorded and she sees an explanation. Dashed paths show the request lost before the checks, or the reply lost after either decision; all three lead to a box saying Sai cannot tell which happened and must reconnect to check her registrations.
Figure 3.8 — A registration request can be accepted, refused, or left uncertain to the visitor.

Every arrow represents a boundary worth checking later. Did the request reach the application? Did the application identify the correct member? Were the rules applied before the record was accepted? Does the displayed message match the stored result? These questions turn a vague claim that “the page works” into observations we can verify.

Que. 20 At which point should Sai be told that her place is confirmed?

Flip to check your answerFold answer back

Answer. After the application has established and recorded an accepted registration. Clicking the button expresses intent; sending a request starts an exchange. Neither alone proves that a place has been secured.

A refusal can be a correct result

Suppose registration closed before Sai submitted. A response explaining that she cannot register is the intended behaviour if the server correctly applies the rule. A successful product is not one that accepts every request; it is one that gives the right result for the circumstances.

Raj’s cancellation follows the same distinction between intent and result. He asks to cancel; the application checks that the registration is his and that cancellation is permitted. An accepted cancellation changes the stored participation and releases capacity under the proposed rules. An unauthorized request must not change another person’s place.

Que. 21 Sam can see an event page, but his request to edit an event he does not manage is refused. Is that necessarily a broken website?

Flip to check your answerFold answer back

Answer. No. Browsing an event and editing it require different permissions. Refusing an unauthorized edit can be the correct result. To judge it, compare Sam’s role for that event with the intended access rule.

When the reply is missing, the outcome may be unknown

Now imagine that Sai submits and her connection stops before she receives the result. There are at least two possibilities: the request never reached the point of recording a registration, or the registration was recorded and the response failed to reach her. The empty or stalled browser page cannot distinguish those possibilities.

The recovery design should let Sai check her registrations after reconnecting. A retry must not create a second active place for the same member and event. This links directly to Chapter 2’s duplicate and confirmation requirements. Do not assume that a missing reply means “nothing happened”, and do not ask a learner to delete records or repeatedly submit to test that guess.

Que. 22 Why is immediately pressing the registration button several more times a poor recovery plan?

Flip to check your answerFold answer back

Answer. The first attempt may already have succeeded. Repeated submissions add requests without resolving what happened. The application should offer an authoritative way to check the result and should prevent duplicate active registrations if a request is repeated.

In practice: handling an uncertain outcome

Situation. An attendee submits a registration, then loses the connection before seeing a result.

Application. Use the journey to distinguish an unreceived request from a completed action whose response was lost. Provide a way to check the current registration state.

Consideration. Do not treat a missing response as proof that nothing changed. Any repeat action must respect the one-registration rule.

Try it yourself: trace and diagnose the journey

On paper, describe Sai’s journey in six stages: locate the host; fetch the event; display it; submit registration; decide and record; show the result. Add two branches: the event is full, and the response is lost after submission. For each branch, state what Sai knows and what the application must ensure. Use the diagrams and Chapter 2’s requirements; no live actions or code are required.

Que. 23 What would a complete model walkthrough contain?

Flip to check your answerFold answer back

Answer. The browser reaches the host and requests the event. The server returns content, which the browser displays. Sai submits a registration request. The application checks identity and current rules, records an accepted result, and returns or redirects to an accurate result page. If the event is full, it refuses the new registration and explains why. If the response is lost, Sai’s outcome is uncertain until she checks stored participation; a repeated request must not create a duplicate.

When something goes wrong

Keep your first trace and correct a copy, so that you can see what changed. Table 3.2 lists the problems a first trace most often has.

Table 3.2 — Trace problems and how to repair them
Problem Check Recovery
The trace treats the screen as the evidence Is there a request and a response behind each claim? Add the method, path, and status from the Network panel or the worked trace.
A reading request changes data Does any GET in the trace register or cancel? Move the change to a POST, and keep the GET for reading the result.
A rule is checked only in the browser Would the rule hold if the page were edited or skipped? Add the server-side check to the trace, and keep the browser check as feedback.
A lost reply is recorded as a failure Could the server have acted before the reply was lost? Mark the outcome uncertain, and add the step that checks current registrations.
PAGE 003

Verify Your Work

There is no code in this chapter. Check your notes and diagrams against Table 3.3 instead.

Table 3.3 — Verification checklist for Chapter 3
Check What to look at Expected result
Address parts One event address, labelled Scheme, host, path, query, and fragment, with the fragment kept in the browser
One exchange A drawing of a page visit A request one way and a response the other, with method and status
Several exchanges Your Network panel record A document row with GET and 200, and separate rows for its resources
Reading or changing The worked registration trace GET for reading; in this example, POST for the change, then a redirect and a GET
Where rules run Your browser and server lists Feedback in the browser; identity, access, window, and capacity on the server
Whole journey Your Step 2 trace Accepted, refused, and uncertain outcomes, each with what Sai sees

If a row is missing, return to the topic it names in What You Need to Know.

PAGE 004

Checkpoint: Quiz and Challenge

Quiz

Que. 24 Which part of https://otahque.example/events/42/?view=details#venue is never sent to the server?

Flip to check your answerFold answer back

Answer. The fragment, venue. The browser keeps it to choose a place on the page.

Que. 25 Why can one page visit produce many requests?

Flip to check your answerFold answer back

Answer. The page document names other resources, such as stylesheets, images, and scripts, and the browser requests each one separately.

Que. 26 What is the difference between a GET request and a POST request?

Flip to check your answerFold answer back

Answer. GET asks to read a resource and should not request a change to product state. POST submits data for the server to process, such as a registration.

Que. 27 Why does the server answer a successful registration with a redirect?

Flip to check your answerFold answer back

Answer. So that the browser then makes a GET for the result page. Refreshing that page repeats only the safe GET, not the registration.

Que. 28 After a lost reply, what should Sai do before trying again?

Flip to check your answerFold answer back

Answer. Check her registrations. The request may already have been accepted, so the current state, not a repeated request, tells her the outcome.

Mini-Challenge

On paper, write the sequence of messages when Raj cancels his registration: each request with its method and path, each response with its status, and what the server checks before it changes anything. Use illustrative paths, as the chapter does. Then mark what Raj should see if the cancellation deadline has passed.

Que. 29 What would a good sequence show?

Flip to check your answerFold answer back

Answer. Raj’s browser sends POST to an illustrative cancellation address. The server checks that Raj is signed in, that the registration is his and still active, and that the deadline has not passed; it records the cancellation and replies 303 with the location of his registrations page. The browser sends GET for that page and receives 200 with the cancelled status. If the deadline has passed, the server changes nothing and replies with a page explaining why; Raj’s registration stays active.

What We Learned

  • A browser asks and displays; a web server receives requests and returns responses, and one page visit can involve many exchanges.
  • An address has a scheme, host, path, query, and fragment; DNS finds the host’s address before the page request, and HTTPS protects the exchange.
  • GET reads and POST requests a change; a redirect after a POST keeps a refresh from repeating the change.
  • The browser can give helpful feedback, but identity, access, time windows, and capacity are decided and recorded on the server.
  • A request can be accepted, refused, or left uncertain when a reply is lost; checking the current state resolves the uncertainty.
  • The browser’s developer tools show the real exchanges, which is better evidence than the screen alone.

Key terms

Use Table 3.4 to check the vocabulary from this chapter before Chapter 4.

Table 3.4 — Key terms from Chapter 3
Term Meaning in this chapter
Browser / client Software that asks for resources and displays or uses responses.
Web server Software handling web requests; also a name for the machine running it.
URL An address identifying a resource; may include query and fragment parts.
DNS / IP address Name lookup / a network address used to reach a destination.
HTTP / HTTPS Web message rules / HTTP protected using TLS.
Request / response The client’s message / the server’s reply.
GET / POST Request information / submit data for processing.
Status / redirect An HTTP result code / a reply directing the browser elsewhere.
HTML / CSS / JavaScript Page structure / presentation / programmable behaviour.
Static / dynamic content Prepared ahead of time / assembled for a request.
Cookie / session Browser-held data sent with matching requests / application continuity across requests.
Database / state Organized stored data / the information currently held.

Readiness checkpoint: You can label the parts of an address, explain the two directions of an exchange, distinguish reading from requesting a change, and place shared rules on the server. You can also explain why a lost reply leaves a registration outcome uncertain. If one step is unclear, revisit its diagram and model answer before moving on.

You have produced a reasoned walkthrough, not a deployed application. Keep it alongside Chapter 2’s requirements: later chapters will turn these messages, decisions, and observations into runnable behaviour and tests.

Git Commit

There is nothing to commit yet. The Otahque project and its Git repository begin in Chapters 6 and 8. Keep your trace and Network panel notes with your other paper work.

PAGE 005

Test Your Knowledge: Interview Questions

These five questions rehearse the chapter at interview level, one at each of five levels from junior to lead. L1 and L2 check what you have just learned. L3 asks how it works underneath. L4 and L5 ask about the design and leadership decisions that later chapters build on: attempt them now, and return to them when you reach those chapters. Use the readiness checkpoint to decide whether to continue. If an answer is difficult, revisit its worked example and explain the result in your own words. L4 and L5 are extension questions, not a gate to the next chapter.

L1 (Junior): What happens between typing an event address into a browser and seeing the page?

What the interviewer is testing: Can you describe the main steps of a page load in order, and name what each one does?

Flip to check your answerFold answer back

Perfect answer: The browser reads the URL and looks up the host name through DNS to obtain an IP address. It connects to that address; with HTTPS it first sets up TLS, which encrypts the connection and lets the browser check the server’s identity. It sends an HTTP GET request for the path. The server replies with a status code, such as 200, headers, and the HTML. The browser reads the HTML, makes further requests for the stylesheets, images, and scripts it names, and then displays the page (Figures 3.3 and 3.5).

Table 3.5 — The steps of a page load and what each one needs
Step What happens What it needs
DNS lookup The host name becomes an IP address The host part of the URL
Connection The browser reaches the server The IP address and port
TLS Encryption and the server’s identity are set up HTTPS in the scheme
Request GET for the path Method, path, and headers
Response Status, headers, and the HTML The server’s decision
More requests Stylesheets, images, and scripts Addresses named in the HTML

Behind the scenes:

1. split the URL; look up the host in DNS
2. connect; for https, negotiate TLS and check the certificate
3. send GET /events/42/ with a Host header
4. read the status; parse the HTML
5. request each resource the HTML names; display the page

Code proof: in the developer tools from Step 1, reload a page and compare the document row with the resource rows that follow it.

Common mistakes:

  • Saying that DNS returns the page.
  • Forgetting the separate requests for images and stylesheets.
  • Describing HTTPS as a different protocol rather than HTTP protected by TLS.

Follow-up the interviewer might ask:

  • “Which of these steps can fail, and what would the visitor see?”
  • “What might be different on a second visit?”

L2 (Mid-Level): Name the parts of a URL, and say which part the server never receives.

What the interviewer is testing: Do you know what each part of an address is for, and what travels in the request?

Flip to check your answerFold answer back
Five numbered steps from top to bottom: the scheme says how to connect; the host says which site; the path says which resource; the query adds an extra value; the fragment stays in the browser.
Figure 3.9 — The five parts of an address and where each one goes.

Perfect answer: In the address in Figure 3.9, the scheme is https, the host is otahque.example, the path is /events/42/, the query is view=details, and the fragment is venue. The fragment stays in the browser: it is not sent in the HTTP request, so the server cannot use it. The path and query are sent to the server, and the host is used to connect and is also sent with the request, in the Host header.

Behind the scenes:

GET /events/42/?view=details HTTP/1.1
Host: otahque.example
# the scheme chose https; #venue was never sent

Code proof (once Chapter 4 has set up Python): Python’s urllib.parse splits the same address:

from urllib.parse import urlsplit

url = "https://otahque.example/events/42/?view=details#venue"
parts = urlsplit(url)
print(parts.scheme, parts.netloc, parts.path)
print(parts.query, parts.fragment)
https otahque.example /events/42/
view=details venue

Common mistakes:

  • Relying on the fragment for a decision on the server.
  • Treating the query as private, although it appears in browser history and server logs.
  • Assuming a path names a file on disk.

Follow-up the interviewer might ask:

  • “Why might view=details be a query rather than part of the path?”
  • “Where could a query string end up recorded?”

L3 (Senior): Why should a form that changes data use POST, followed by a redirect?

What the interviewer is testing: Do you understand safe methods, repeated submissions, and the Post/Redirect/Get pattern?

Flip to check your answerFold answer back
Five numbered steps from top to bottom: POST submits the registration; the server checks the rules and records it; 303 See Other names the result page; the browser makes a GET for that page; a refresh repeats only the GET.
Figure 3.10 — Post, redirect, get.

Perfect answer: GET is for reading. It should not request a change to product state, because browsers, crawlers, and link previews may repeat or follow GET requests. Registering changes data, so the form uses POST. If the server answered the POST directly with a page, refreshing that page would ask the browser to send the POST again. With Post/Redirect/Get, the server processes the action and replies 303 See Other with the result page’s location; the browser then makes a GET for that page, so a refresh repeats only the GET (Figure 3.6). The server must still handle a repeated submission correctly, because a redirect does not stop someone sending the POST again.

Behind the scenes:

POST /registrations/      -> 303 See Other
                             Location: /registrations/mine/
GET /registrations/mine/  -> 200 OK, the result page
# 303 tells the browser to follow with GET, whatever the
# original method was

Evidence: Figure 3.6 provides the worked Post/Redirect/Get trace. If you observe a harmless form you already intended to use, check whether it follows this pattern rather than assuming that it must. A form can use GET, return a response directly, or submit through JavaScript. Do not submit a registration or another consequential action merely to perform this exercise.

Common mistakes:

  • Using a plain link, which is a GET, to cancel a registration.
  • Believing the redirect alone prevents duplicates.
  • Returning a successful change’s result page directly when the intended design should make refresh repeat only a GET. Returning an invalid form with errors directly is a different, normal case.

Follow-up the interviewer might ask:

  • “Why 303 rather than 302?”
  • “What else stops a member registering twice?”

L4 (Staff): The browser hides the Register button when an event is full. Is that enough?

What the interviewer is testing: Do you know where rules must be enforced, and why the browser cannot be trusted?

Flip to check your answerFold answer back
Five numbered steps from top to bottom: the browser shows helpful feedback; anyone can edit or skip the page; the server rechecks every rule; only accepted results are recorded; the response explains the outcome.
Figure 3.11 — Feedback in the browser, decisions on the server.

Perfect answer: No. Everything in the browser is under the user’s control: the page can be changed, scripts can be turned off, and requests can be sent without the page at all. Hiding the button is helpful feedback, but on every request the server must check identity, access, the registration window, and capacity, and record only accepted results (Figure 3.7). The trust boundary is where browser data enters the server, and everything that crosses it is untrusted input. Checks in the browser improve the experience; checks on the server enforce the rules.

Behind the scenes:

1. edit the page in the developer tools to show it again
2. send the POST directly with any HTTP tool
# both reach the server; only its checks stop them

Evidence: Figure 3.7 places each decision on its side of the boundary.

Common mistakes:

  • Treating checks in the browser as security.
  • Trusting hidden form fields.
  • Checking the rule when the page is displayed but not when the form is submitted.

Follow-up the interviewer might ask:

  • “What should the server send back when it refuses?”
  • “Which browser checks are still worth having?”

L5 (Lead): A member reports being registered twice after a slow connection. How do you lead the investigation and prevent it happening again?

What the interviewer is testing: Can you move from a report to evidence, a root cause, a lasting fix, and shared learning?

Flip to check your answerFold answer back
Five numbered steps from top to bottom: gather evidence of both requests; find the root cause; enforce one active registration on the server; improve the experience; share a blame-free note.
Figure 3.12 — From one report to a lasting fix.

Perfect answer: Start with evidence, not a theory. Find both requests in the server’s records, with their times, methods, and outcomes, and compare them with what the member saw. Then look for the root cause among the usual candidates: a slow or lost reply that invited a second click (Figure 3.8), a double click, a missing redirect after the POST, or no rule against duplicates on the server. Whatever started it, the lasting fix is the same: enforce one active registration per member and event where the result is recorded, so that a repeated request returns the existing registration instead of creating another. Then improve the experience, by showing progress while a request is in flight and by showing members their existing registrations. Correct the member’s record, add a test that repeats the request, so that the problem cannot return unnoticed, and share a short, blame-free note on what happened and what changed.

Behind the scenes:

18:02:10  POST /registrations/  (first click)
18:02:14  no reply reaches the browser
18:02:20  POST /registrations/  (second click)
# without a server rule, both POSTs create a registration

Evidence: Figure 3.8 shows the lost reply that makes a second click likely, and Chapter 2’s PR-1 states the rule the server must keep: one current confirmed place.

Common mistakes:

  • Blaming the member for clicking twice.
  • Fixing only the button, so that a repeated request from elsewhere still creates a duplicate.
  • Deleting the duplicate without finding what allowed it.

Follow-up the interviewer might ask:

  • “How would a repeated request return the same result?”
  • “What do you tell the member while the fix is in progress?”

Next: Chapter 4 prepares your Python and development tools.

PAGE 006