Use Of Different HTTP Methods

Hi guys, hope you are all doing well!
Today, I'm stuck on something which I never thought about throughout my entire developer journey.
It's about HTTP methods. We've read about different types of HTTP methods like ๐๐๐, ๐๐๐๐, ๐๐๐, ๐๐๐๐๐๐, ๐๐ง๐ ๐๐๐๐๐, and we also know they each have different purposes.
But technically, if we want to update a document in the database, we can use any HTTP method! It depends entirely on the developer's logic implemented in that route. So, this causes confusion. Why do we even have these different methods? (We all have a sense that ๐๐๐ is used for fetching data from the server.) But what about ๐๐๐, ๐๐๐๐๐, ๐๐ง๐ ๐๐๐๐? What's their real purpose?
Finally, I understood: there is no strict technical limitation between these methods. The key difference lies in using them according to standard conventions. According to RESTful APIs, we must follow specific rules to clearly express our intent. For instance:
- ๐๐ ๐ฐ๐ ๐ฐ๐๐ง๐ญ ๐ญ๐จ ๐๐ซ๐๐๐ญ๐ ๐๐๐ญ๐, ๐ฎ๐ฌ๐ ๐๐๐๐.
- ๐๐ ๐ฐ๐ ๐ฐ๐๐ง๐ญ ๐ญ๐จ ๐ซ๐๐ฉ๐ฅ๐๐๐ ๐๐จ๐ฆ๐ฉ๐ฅ๐๐ญ๐ ๐๐๐ญ๐, ๐ฎ๐ฌ๐ ๐๐๐.
- ๐๐ ๐ฐ๐ ๐ฐ๐๐ง๐ญ ๐ญ๐จ ๐ฉ๐๐ซ๐ญ๐ข๐๐ฅ๐ฅ๐ฒ ๐ฎ๐ฉ๐๐๐ญ๐ ๐๐๐ญ๐, ๐ฎ๐ฌ๐ ๐๐๐๐๐.
Additionally, browsers optimize these requests according to their behavior. For example, POST or other update requests are never cached. Moreover, REST clients might get confused if you write update logic inside a POST request.
In short, itโs about meaning, not limitation.
Final Answer: Clearly communicate intent, follow standards, and avoid confusion.
Thank you for your time reading this ๐.
If you have any suggestions regarding this comment, let's learn together!
Subscribe to my newsletter
Read articles from Hari Krishnan P U directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
