Wednesday, 21 November 2012

Difference between GET & POST

Features
GET method
POST method
Fundamental Difference is probably the Visibility
GET request is sent via the URL string (appended to the URI with a question-mark as separator), which is visible.
POST request is encapsulated in the body of the HTTP request and can't be seen.
Length
Since, GET request goes via URL, so it has a limitation for its length. It can't be more than 255 characters long.
No such maximum length limitation holds for the POST request for the obvious reason that it becomes a part of the body of the HTTP request where there is no size limitation.
Performance
GET request is comparatively faster as it's relatively simpler to create a GET request.
Much time spent in the encapsulation of the POST request in the HTTP body .
Type of Data
GET request is sent via URL string and as we all know that URL can be text-only, so GET can carry only text data.
POST has no such restriction and it can carry both text as well as binary data.
Caching/Bookmarking
It can be cached as well as Bookmarked because GET request is nothing but an URL.
No such luxuries with a POST request.
FORM Default
GET is the default method of the HTML FORM element.
To submit a FORM using POST method, we need to specify the method attribute and give it the value "POST".
Data Set
GET requests are restricted to use ASCII characters only.
POST requests can use the 'enctype' attribute with a value "multipart/form-data" to use the Universal Multiple-Octet Coded Character Set (UCS).

No comments:

Post a Comment