Table of Contents
*This post may contain affiliate links. As an Amazon Associate we earn from qualifying purchases.
If the topic of Get vs Post and the difference between the two has been on your mind, you’ll find the answer to your question in this article.
When you sing up or log in, you have to enter an email, credentials, and other personal information to gain access to the website. Any programmer knows that this information is put into an HTML form, which is used to transfer information to a web server from a web browser.
For instance, you have to put your username and password into an HTML form when you log into an email provider such as Gmail or Yahoo.
Users pass this information from their web browsers to one of Google?s or Yahoo?s web servers when they hit the ?Sign in? button. In other words, the authentication process is the key to transferring this information.
However, if we search deeper, we will see that there are two distinct methods, known as GET vs POST, to submit a form from your browser to a web server. That is why programmers are regarded as the archeologists of the IT world.
Both submission options will appear in the following form tags in HTML: <form method=?POST?> and <form method=?GET?>.
When either one of this methods is submitted, the data is passed to the web server through a generated HTTP request. HTTP can be regarded as the language used by the user?s web browser to communicate with web servers.
GET request Example
When the ?GET? request method is used, a query string is developed containing the URL encoded parameters. The form parameters can be represented by anything, just like in the previous example where they would be the credentials for the email provider.
It is worth mentioning that defining a login form to use the method of GET request is one of the worst possible ideas because the users who will log in will have their passwords displayed in the URL. When they see their passwords, they will think that the website security is low.
That is why when it comes to passwords, a good programmer will use a POST request in most cases. One difference between GET and POST is that the form parameters from the POST request are passed into the HTTP request body and not in the URL.
This is another example of HTTP communication between the web server and the user?s web browser.
Top difference between POST and GET
The most important difference in the GET vs POST?duel is that GET requests are usually idempotent, depending on the programmer?s choice. Idempotence is made of multiple GET requests, which have the exact form parameters (meaning that the URL will be identical as well), will lead to the same consequences as a single GET request.
On the other hand, POST requests are not designed to be idempotent, so they cannot be cached. For queries such as a shopping cart, a POST request is more appropriate because the response page changes over time.
As a programmer it is best to remember in a GET vs POST situation, that the GET method won?t prevent? changes. Browsers are designed and usually coded to receive POST requests which will be an important tool to cause changes such as writing to a database or placing an order. GET requests are more suited for pure queries which do not affect the server in any way.