The Web is a service on the Internet. The Internet provides pipes. The Web provides hypertext and the browser interface.
Learning Objectives
By the end of this chapter, you will be able to:
- Distinguish the Internet from the World Wide Web.
- Explain hypertext, HTML, and HTML5.
- Describe the HTTP request-response cycle and HTTPS.
- Parse a URL and explain HTTP status codes.
- Explain web browsers, web servers, application servers, and databases.
- Contrast static and dynamic pages and explain cookies and sessions.
1. Internet versus Web
- Internet: Global network of physical links, routers, and TCP/IP. It carries many services: Web, email, VoIP, streaming.
- World Wide Web: System of interlinked hypertext documents. Tim Berners-Lee proposed it at CERN in 1989 and released it in 1990-1991. Browsers fetch pages over HTTP, render HTML and CSS, and run JavaScript.
The Internet can exist without the Web. The Web cannot exist without the Internet.
2. Hypertext and HTML
Hypertext links one document to another. HTML (Hypertext Markup Language) structures the document with tags for headings, paragraphs, images, links, and forms. HTML5 added native video, audio, and offline storage, so modern stores run without browser plugins. CSS styles the layout. JavaScript adds interactivity such as filtering products without reloading the page.
Clean HTML improves SEO and accessibility.
3. HTTP and HTTPS
HTTP (Hypertext Transfer Protocol) defines the conversation between browser (client) and server.
- Client opens TCP to the server IP and sends a request: method, path, headers. Example: GET /products/laptop HTTP/1.1
- Server processes the request, queries application logic and database if needed, and returns a response: status code, headers, body.
HTTPS wraps HTTP inside TLS encryption. TLS provides confidentiality, integrity, and server authentication via certificates. Browsers show a padlock when TLS is active. E-commerce must use HTTPS for every page that collects input, not just checkout, because login cookies travel on every request.
sequenceDiagram
participant B as Browser
participant S as Web Server (Nginx)
participant A as App Server
participant D as Database
B->>S: GET /products/laptop over TLS
S->>A: Forward request
A->>D: SELECT price, stock WHERE sku = ?
D-->>A: Row returned
A-->>S: HTML + JSON
S-->>B: 200 OK + body
Figure 1: Request-response cycle for an e-commerce product page
4. URLs, status codes, and what the server returns
URL = Protocol + Domain + Path (+ query). Example: https://www.daraz.com.np/products/laptop?color=silver
- https:// declares protocol and encryption.
- www.daraz.com.np is the domain that DNS resolves.
- /products/laptop is the path. ?color=silver is a query parameter.
HTTP status codes tell the browser what happened.
| Code | Meaning | E-commerce trigger |
|---|---|---|
| 200 | OK | Product page rendered |
| 301 | Moved permanently | Old product URL redirects to new slug, preserves SEO |
| 404 | Not found | Deleted product shared on Facebook |
| 500 | Internal error | Checkout code threw an exception |
| 503 | Service unavailable | Overload during 11.11 sale, retry after header set |
A rise in 503 signals capacity failure.
5. Browsers and servers
- Browser: Chrome, Firefox, Safari, or in-app WebView. It resolves DNS, negotiates TLS, renders HTML/CSS, and stores cookies.
- Web server: Nginx or Apache can listen on port 443 for HTTPS requests, serve static files, and forward dynamic requests.
- Application server: Runs PHP, Python, Node.js, or Java. It checks stock and builds HTML per user.
- Database: Stores catalog, users, carts, and orders.
Scale each tier separately with CDN, app servers, and read replicas.
6. Static versus dynamic pages
| Dimension | Static page | Dynamic page |
|---|---|---|
| Content | Same for every visitor | Built per request from database and user context |
| Source | Fixed HTML file on disk or CDN | Template filled by application server |
| Example | About us, return policy | Search results, cart, order history, recommendations |
| Strength | Fast, cheap, cacheable, secure | Personalized, always current |
| Weakness | Cannot personalize | Slower, needs database, harder to cache |
Cache static pages at the edge. Generate dynamic pages on demand.
7. Cookies and sessions
HTTP is stateless. Each request stands alone. Shopping requires memory.
- Cookie: Small text file the server sets in the browser. The browser returns it on every request to that domain.
- Session: Server-side record keyed by a session ID stored in the cookie. It holds cart items, login state, and CSRF tokens.
Add to cart sets a session cookie. Checkout reads the same ID and retrieves the cart. First-party cookies sustain the shop. Browsers now block third-party cookies.
8. Evolution of the Web
| Stage | Core shift | E-commerce consequence |
|---|---|---|
| Web 1.0 (1990s) | Read only, publisher centered | Brochure sites, limited transactions |
| Web 2.0 (2000s) | User generated content, reviews, social | Ratings, photos, social commerce drive trust |
| Mobile web (2010s) | Smartphones first | Responsive design, wallets, COD |
| Semantic and AI web (2020s) | Machines understand content, generative assistance | Rich results, AI search, recommendation engines |
Many Nepali users skipped desktops. Phones came first, so responsive and light pages win.
Worked Example: How much page weight matters on Nepali mobile data
In BS 2081, a Kathmandu store serves a product page that weighs 3.2 MB. After optimization it serves 1.1 MB by compressing images to WebP, deferring non-critical JavaScript, and caching via CDN.
A customer on a 100 MB daily mobile pack opens 25 product pages per day.
- Before: 25 x 3.2 MB = 80 MB per day.
- After: 25 x 1.1 MB = 27.5 MB per day.
- Saving: 52.5 MB per day, or 52.5 percent of the pack. At NPR 40 per 100 MB, the saving funds two extra wallet transactions. Conversion rises because pages finish in 2 seconds instead of 5 on 4G.
Self-Check Define in one sentence each: hypertext, URL, HTTP, and cookie. Then state one risk of running checkout on HTTP instead of HTTPS.
Self-check
Why should a checkout use HTTPS rather than plain HTTP?
Try This A product listing API returns 200 OK in 80 ms without cache and 18 ms with cache. Assume the category page calls the API 6 times sequentially and adds 40 ms network latency per page. Calculate total time before and after caching and decide whether caching moves it under a 200 ms budget. Show steps.
Answer sketch
Without caching: 6 × 80 + 40 = 520 ms. With caching: 6 × 18 + 40 = 148 ms, which is below the 200 ms budget. Real page load time also depends on other resources and whether requests run in parallel.Summary
The Internet carries the Web. Hypertext written in HTML creates linked documents. HTTP defines the request and response. URLs locate resources. Status codes report outcomes. Browsers render and execute. Servers handle static files and delegate dynamic work to application servers and databases. Static pages are fixed and cacheable. Dynamic pages are assembled per request. Cookies store an identifier and sessions store state, which makes carts possible on a stateless protocol. HTTPS is mandatory for any interaction that handles logins or payments.
Key Takeaways
- Internet is infrastructure; Web is a service on top of it.
- HTML structures, CSS styles, JavaScript animates, HTTP transports.
- Every request returns a status code; monitor 4xx and 5xx separately.
- Dynamic pages need databases and benefit from fragment caching.
- Cookies carry identity; sessions hold state; HTTPS protects both.
Discussion
- Why should a shop use HTTPS for browsing as well as checkout?
- When might a static page be preferable to a dynamic page, and what information might still need to be updated?
- How do cookies and server-side sessions help a shopping cart remember its contents?
Exercises
Short answer
- Distinguish the Internet from the Web.
- Parse https://www.example.com.np/search?q=shoes into protocol, domain, path, and query.
- State what 301, 404, and 503 mean.
- Why is HTTP called stateless and how does a cart remember items?
Long answer
- Draw and explain the request-response cycle when a customer opens a product page, including browser, web server, application server, and database.
- Compare static and dynamic pages with Nepali e-commerce examples and state when to cache each.
- Explain cookies and sessions with a checkout flow and note privacy changes around third-party cookies.


