views:

164

answers:

6

Is POST more compact than GET, since GET requests have to be URL-encoded?

+5  A: 

Both have completely different purposes, so I wouldn't compare them in that way. GET is for data retrieval, and should have no side effects beside that. And POST is for sending data, not retrieving them.

PiotrLegnica
+4  A: 

So are POST. They're equally compact. It's a matter of where the data go. For POST it goes into request body. For GET — into URL itself. Moreover, in case of multpart/form-data encoding (which is required for file uploads, but in this case GET request is not an option, anyway) POST will be more verbose.

Michael Krelin - hacker
+2  A: 

No, POST requests still have to be put into the http query. You just don't see them as part of the URL.

IE here's a get query

  GET <url with params>

vs a post query

  POST <url>
  ...
  <params>
Doug T.
+2  A: 

POST has one more letter in it than GET, so it's less compact.

If compactness is very important and you don't care about HTTP semantics, use a binary protocol instead. The semantics of POST and GET are different, and HTTP is not optimised for compactness.

Pete Kirkham
+2  A: 

You might want to review the following information regarding get vs post usability. http://www.w3.org/2001/tag/doc/whenToUseGet.html

To sum it up:

use GET if:

The interaction is more like a question. For example, lookups, read only operations, etc.

use POST if:

The interaction is more like an order, changes the state of a resource, or the user will be held accountable for the results of the interaction.

Note that none of this takes into account the SIZE of the request. For more thought, you might consider the early days of the internet when search engines caused database problems simply by performing GET requests on the links they crawled. This was because some programmers used GET requests to change the state of resources (such as deleting records, dropping tables, etc).

Chris Lively
I would imagine that a fair number of web sites still mis-use GET to change state.
Will Bickford
+1  A: 

Just a quick note: According to Yahoo YUI team and YSlow, when using XMLHttpRequest objects (AJAX), POST almost always uses two packets, while GET will use one (content length permitting).

This means that your AJAX requests are "more compact" if you use GET.

Source:

http://developer.yahoo.com/performance/rules.html#ajax_get

Toby