Difference between POST and GET Method

By | May 24, 2020
POST vs GET

There are lots of Protocols associated with the Internet and HTTP is one of them. Hypertext Transfer Protocol (HTTP) deals with the communication between the server and the client and works as a request-response protocol between the client and the server. Through this article, you will get a detailed comparison between POST vs GET Method.

When we use a Web Browser and visit any website, on the URL bar we can see that htttp before the www. Most of the websites have https here to represent that the website is secure.

Vamware

Difference between POST and GET

HTTP has many methods such as GET, POST, PUT, HEAD, DELETE, PATCH, and OPTION. Here in this article, we will compare the two most used HTTP methods GET and POST.

We use POST and GET methods with the HTML forms when we create a Form using HTML, we pass the method along with the Form tag and these methods operate on the data that a client passes on that form when he/she fills it. Both GET and POST get a request from the user or client and communicate with the server. When we use the POST method it supplies all the filled information in the message body but when we use the GET method it includes all the filled data in the URL.

POST vs GET: Head to Head Comparison

Parameters POST GET
Data Parameters It does not store and includes the data parameters in the URL or anywhere on the client system It includes the data parameters in the URL which can store in the browser history and the security of the client can be compromised.
Bookmark As the data does not include in URL so there is no concept of Bookmark The get request data can be Bookmarked
Reload the page The data will be resubmitted. The page will be re-executed but not re-submitted, it does not send any request to the host because it is saved in the cache memory.
Security POST provide security over the data It does not provide any security
Cache No cache There can be caches
Data length There is no limit for data length It has a limit of 2048 characters.
Data type All data types are allowed Only accept ASCII characters
Data visibility Data is not visible to everyone Data is visible to everyone
Use We use the POST method with sensitive data like password GET used with insensitive data.

POST vs GET: Working With Form Submission

Though GET and POST have different features, they both serve the same purpose. The process of submission of data by the client commences with the same manner for both the methods when a form is filled and the client submits the form data.

1. Method = ‘GET’ After the for submission the get method creates a URL with the help action attribute which passes along the form tag and appends it with the data given by the client.

Example:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="page.php" method="GET">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

2. Method = ‘POST’ In post after the form submission by the client it uses the action attribute to create a message according to the content type specified by the enctype attribute.

Example:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="page.php" method="POST">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="pwd">
<input type="submit" value="Submit">
</form>
</body>
</html>

Pros & Cons of GET method

Pros

  • It is SEO friendly method
  • Easier to set up for the small non-secure data.
  • It can be cached
  • Faster process

Cons

  • Does not have a request body
  • Data security is the main concern
  • Only accept ASCII characters
  • Data length has limits

Pros & Cons of using the POST method

Pros

  • It can send data to the server in invisible mode
  • Does not have any data length limit
  • Any kind of data could be sent using the POST method

Cons

  • The client has to send data again if we reuse that page normally it causes warning in the web browser.
  • No cached that means we cannot save pages for a long period.

You may be also interested in:

Leave a Reply

Your email address will not be published. Required fields are marked *