HTTP Methods and Their Use Cases

The Hypertext Transfer Protocol (HTTP) is the foundation of communication on the web. Every time you interact with a website—whether you’re browsing, submitting a form, or uploading a file—your browser sends an HTTP request to the server. This request specifies an HTTP method, which tells the server what kind of action is being requested.
1. GET
Purpose: Retrieve data from a server.
Characteristics:
Safe (does not modify data).
Can be cached by browsers.
Appends data to the URL (as query parameters).
Example Use Cases:
Loading a webpage (
GET /index.html
).Searching on Google (
GET /search?q=chatgpt
).Fetching product details in an e-commerce store.
2. POST
Purpose: Submit data to the server (usually to create or update a resource).
Characteristics:
Not cached by default.
Data is sent in the request body (not in URL).
Can change server-side data.
Example Use Cases:
Logging into a website (sending username & password).
Submitting a contact form.
Uploading an image or file.
3. PUT
Purpose: Update or replace an existing resource on the server.
Characteristics:
Idempotent (repeating the same request gives the same result).
Sends complete resource data (not partial).
Example Use Cases:
Updating a user profile (
PUT /users/123
).Replacing an article in a blog system.
4. PATCH
Purpose: Partially update an existing resource.
Characteristics:
Unlike
PUT
, only the changed fields are sent.More efficient for small updates.
Example Use Cases:
Changing only a user’s email address (
PATCH /users/123
).Updating the price of a product without altering other details.
5. DELETE
Purpose: Remove a resource from the server.
Characteristics:
- Idempotent (deleting the same resource multiple times has the same effect).
Example Use Cases:
Deleting a blog post (
DELETE /posts/45
).Removing an item from a shopping cart.
6. HEAD
Purpose: Retrieve metadata (headers) of a resource without fetching the body.
Characteristics:
Similar to
GET
but only returns headers.Useful for checking if a resource exists or validating cache.
Example Use Cases:
Checking if an image exists on a server before downloading.
Verifying last-modified date of a file.
7. OPTIONS
Purpose: Find out which methods are allowed for a resource.
Characteristics:
Returns supported HTTP methods in the
Allow
header.Often used in CORS (Cross-Origin Resource Sharing).
Example Use Cases:
Browser checking which methods are supported before making a request.
Security testing of APIs.
8. CONNECT (less commonly used)
Purpose: Establish a tunnel to the server (often for HTTPS via a proxy).
Example Use Case:
- Secure SSL/TLS connections through an HTTP proxy.
9. TRACE (rare, mostly disabled for security)
Purpose: Echoes the received request for debugging.
Example Use Case:
- Debugging or diagnosing request path (though usually disabled due to security risks like XSS).
Real-World Analogy
Think of HTTP methods like actions you perform at a library:
GET → Reading a book.
POST → Donating a new book.
PUT → Replacing an old book with a new edition.
PATCH → Updating a single chapter in a book.
DELETE → Removing a book from the library.
HEAD → Checking only the book’s metadata (title, author).
OPTIONS → Asking the librarian what services you can use.
Why HTTP Methods Matter?
They define clear communication between client and server.
They make APIs RESTful and predictable.
They ensure security and efficiency in web applications.
They help developers build scalable systems where each action has a defined purpose.
Subscribe to my newsletter
Read articles from Jeet Vamja directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
