Is POST more compact than GET, since GET requests have to be URL-encoded?
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.
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.
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>
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.
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).
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: