Serksa
All Concepts
API & Backend

Request & Response

1

What is it?

A <strong>request</strong> is when a client asks for something, and a <strong>response</strong> is what the server sends back. This is the fundamental conversation pattern of the web.

2

Think of it like...

The Question and Answer

Like asking a librarian for a book and getting it back, every web interaction is a request-response cycle.

Request

The question

💬

Processing

Thinking

Response

The answer

3

Visual Flow

📱Request

GET /profile

⚙️Server

Processing

📄Response

200 OK + Data

4

Where you see it

1

Client Sends Request

Includes: URL, method (GET/POST), headers, maybe data

2

Server Receives

Server reads what you're asking for

3

Server Processes

Runs code, queries database, prepares response

4

Server Sends Response

Includes: status code (200, 404), headers, data

5

Client Handles Response

Shows success, error, or the data you requested

5

Common Mistake

Wrong

The connection stays open the whole time you're on a website

Correct

Each request-response is a separate conversation. After the server responds, the connection usually closes. Your browser makes many separate requests for images, CSS, data, etc.

💡 Real-World Example

Loading a Twitter page:

1

Request 1: GET /home → Response: HTML page

2

Request 2: GET /profile-pic.jpg → Response: Your photo

3

Request 3: GET /api/tweets → Response: Latest tweets data

4

Request 4: POST /api/like → Response: Success confirmation

5

Each is a separate request-response cycle