What is HTTP? Differentiate its persistent and non-persistent types with request-response behavior of HTTP.
Understanding HTTP: Persistent vs. Non-Persistent Connections
What is HTTP?
- HyperText Transfer Protocol (HTTP) is the foundation of data communication for the World Wide Web.
- It's an application layer protocol that defines how clients (like web browsers) and servers exchange information.
- Uses a client-server model.
- Primarily uses TCP for reliable data transmission.
HTTP Request-Response Behavior
- A client initiates a request to the server (e.g., requesting a webpage).
- The server processes the request.
- The server sends a response back to the client (e.g., the webpage content).
- The response includes a status code indicating success or failure.
Non-Persistent HTTP
- One TCP connection is used for one request-response cycle.
- The connection is closed after each response.
- More overhead due to repeated connection establishment and termination.
- Simpler to implement.
Persistent HTTP
- A single TCP connection can handle multiple request-response cycles.
- The connection remains open until explicitly closed or timed out.
- Reduces overhead by avoiding repeated connection establishment.
- Improves performance, especially for web pages with multiple components (images, scripts).
Persistent HTTP Connection Management
- Server keeps the connection open for a specified time or until a certain number of requests are handled.
- Client may send multiple requests over a single persistent connection.
- Pipelining: Client can send multiple requests consecutively without waiting for responses. Server handles them in order.