Sunday, 22 April 2012

GET vs POST: Which one is better? A 10 point comparision

1. Data Size Restriction in GET: There is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new ones can handle more than that. But we can't be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in POST method. We can transfer unlimited data using POST. In PHP by default 8MB of data can be transferred. (can be changed by setting the post_max_size in the php.ini file)

2. Data Type Restriction in GET: As the data transfers through address bar ( URL ) there are some restrictions in using space, some characters like ampersand ( & ) etc in the GET method of posting data. We have to take special care for encoding (while sending) and decoding (while receiving) data if such special characters are present.

3. Security: In GET method data gets transferred to the processing page in name value pairs as a query string in URL, so it is exposed and can be easily traced by visiting history pages of the browser. Data is always submitted in the form of text. So any login details with password should never be posted by using GET method. On the other hand, POST is much more secure. In case of POST, all the name value pairs are submitted in the Message Body of the request.

4. Speed: GET is faster than POST.

5. Bookmarking: There are some special cases where advantage of using GET method is, one can store the name value pairs as bookmark and directly use them by bypassing the form. But you cannot bookmark using POST method.

6. If POST method is used and if the page is refreshed it would prompt before the request is resubmitted but it would not prompt if GET method is used.

7. Uploading files through input type file is possible in POST but not with GET method.

8. There are chances for data lost after server encoding in GET method but no data loss occurs in case of POST method.

9. GET uses STACK method for passing form variables while POST method uses HEAP method for passing form variables.

10. GET can store up to 18 form variables but there is no limit in case of POST method.

11 comments:

  1. 1- That 255 figure came from the HTTP 1.1 RFC, released in 1999. i.e. in 1999 old browsers only supported small numbers of characters. In 2012, all browsers anyone might ever use do.

    2- You should ALWAYS take special care when encoding into either GET or POST. There are other serious security errors if you don't, so you need to do it as a matter of course.

    3- True. Also CSRF attacks are a bit harder to perform if requests require POSTs.

    4- I don't see how it is faster. Seems dubious to me! Maybe a microsecond or so.

    5- True.

    6- True.

    7- True.

    8- I don't think that's true.

    9- Interesting, not heard this. I wonder if it is in the RFCs, or if it is language-specific.

    10- Maybe that is language specific. I know it is definitely not true in PHP, unless Suhosin restrictions are placed.

    ReplyDelete
  2. I think you really mist the most important difference: They have different semantics! POST is for posting stuff. GET is for getting a resource.

    Lots of your other points are just corollary to that.

    ReplyDelete
  3. Utter bullshit

    ReplyDelete
  4. Learner should take into consideration when choosing the right accelerated online degree program. Students will have better opportunities if they decide to take a course online. For further details visit http://www.betteronlinedegrees.com/.

    ReplyDelete
  5. Hi! Great blog for anyone looking for topic-specific info. I learned something today, thanks!

    ReplyDelete
  6. I think you really mist the most important difference: They have different semantics! POST is for posting stuff. GET is for getting a resource.

    ReplyDelete
  7. Top Classified Sites List, Top Hot Current Affairs in the World, Most Popular Pictures, Loll Pictures, Funny Pictures, Funny Videos, Current Affairs Videos, Entertainment News and Videos, Entertainment Pictures, Hot Girls Affairs and all hot Current Affairs in the World
    HotCurrentAffairs.com

    ReplyDelete
  8. Thanks for the quick reference you have created for GET vs POST. I have put a FAQ regarding HTTP GET and POST on my blog post, do let me know if you like it.

    ReplyDelete
  9. Thank you for sharing this essay, I hope you can create more essay and research on your topic. It will be great to see a more entertaining and informative post.

    ReplyDelete
  10. I love this! I am in a bit of a time crunch so hope to be able to come back later and chat more. And not that this is the most important thing but college essay writing help don't know if you like all skating or just Brian Orser but I find it fascinating that there is a figure skating mention in each of our posts!!

    ReplyDelete