What is the PATCH method?
The PATCH method
The PATCH method is an HTTP verb used to apply partial modifications to a resource.
Unlike PUT, which completely replaces an entire resource with a new representation, PATCH only sends the specific data fields that need to be changed.
Think of it like updating a user's profile:
- If you use PUT, you must send the entire profile back to the server (name, email, age, address, etc.), even if you only changed their email address.
- If you use PATCH, you tell the server: "Just update the email address to this new value, and leave everything else as it is."
Why use PATCH?
The primary advantage of PATCH is efficiency. By only sending the data that changed, you use less bandwidth and reduce the workload on the server. This is especially important for mobile applications or APIs dealing with very large and complex data structures.
Support and adoption
While PUT was part of the original HTTP/1.1 specification and has been ubiquitous since the beginning, PATCH was added later (officially defined in RFC 5789 in 2010). Because of this, it historically had slightly varying levels of support across different web servers and frameworks.
Today fetch(), API tools and major web frameworks (like Ruby on Rails, Django, and Express) all support PATCH. HTML forms still can't send it directly, which is why Rails spoofs it. It is now the standard choice for partial updates.
Keep going with lesson 2
Anatomy of a PATCH request
Shows a PATCH request whose body is a small patch document containing only the fields being changed.
A free account also gives you the quizzes, your progress and notes, and the discussion.