Day 1: Web Dev cohort
/ 3 min read
Table of Contents
GET /path/to/resource HTTP/1.1Host: example.comUser-Agent: Browser/Version
HTTP Overview:
- Full Form: Hypertext Transfer Protocol
- Purpose: Transfer hypertext links (web documents)
- Definition: Set of rules for data communication
- Key Characteristics:
- Human-readable
- Stateless protocol
- No memory of previous requests
- Behavior: Processes each page/request as new, without maintaining user state
Session and Cookie Overview:
- Purpose: Maintain user state between frontend and backend
- Key Characteristics:
- Shared between browser (client) and server
- Bidirectional communication
- Cookie Functionality:
- Server can send cookie to browser
- Browser can send cookie to server
- Transfers information/data between systems
- Core Concept: Enables persistent user information exchange
Web Request-Response Model:
Key Components:
-
Action Type (HTTP Methods)
- GET
- POST
- DELETE
- PUT
-
Location (URL)
- Example: http://google.com
-
Response Status
- Indicates action completion
- Response Codes Example:
- 200: Successful
- 404: Not Found
- 500: Server Error
- 403: Forbidden
- 302: Redirect
Core Concept:
- Browser sends request to server
- Server processes request
- Server sends back response
- Response indicates whether action was successful
Understanding HTTP/2: Modern Web Communication Protocol
Overview of HTTP Versions
HTTP/2 represents the modern standard for web communication, with HTTP/1.1 serving as the primary fallback protocol. Interestingly, HTTP version 1 was never officially released, with HTTP/1.1 being the predecessor to the current HTTP/2.
Key Features of HTTP/2
1. Data Compression
HTTP/2 introduces significant improvements in data transfer efficiency through compression. This means:
- Data is compressed (zipped) during transfer
- Reduced data size
- Faster request and response processing
2. Multiplexing
A revolutionary feature of HTTP/2 is its ability to handle multiple requests simultaneously:
-
Can manage multiple request-response cycles concurrently
-
It used a single TCP connection between the client and the server for a given origin, this allowed for a faster transfer for the data.
-
Overcomes limitations of HTTP/1.1, where:
- Only one request could be processed at a time
- A single user was restricted to one request-response cycle
Protocol Evolution
- HTTP/1.1: Initial standard protocol
- HTTP/2: Current modern web communication protocol
- Fallback mechanism ensures compatibility with older systems
The introduction of HTTP/2 significantly improves web communication efficiency, reducing latency and enhancing overall performance.
Understanding Basic HTTP/HTTPS Communication
Initial Connection Establishment
When a browser initiates communication with a server, the process begins with a crucial security step:
- TLS Handshake
- The browser and server exchange TLS (Transport Layer Security) certificates
- This ensures a secure, encrypted connection
Request Transmission
The browser sends a comprehensive request to the server, which typically includes:
- HTTP method (e.g., GET, POST)
- Complete URL
- Additional request headers
- Potential request data
Server Response
The server processes the request and responds with:
- Status code (indicating request success or failure)
- Response body
- TCP connection details
Key Characteristic: Stateless Communication
Important Note: HTTP is fundamentally stateless, meaning each request-response cycle is independent. The server does not inherently maintain information about previous interactions.