Page 1 of 1

differences betweenGET andPOST

Posted: Thu Sep 30, 2010 12:30 am
by ali0482
What are the differences betweenGET andPOST methods in form submitting, give the case where we can use get and we can use post methods

Re: differences betweenGET andPOST

Posted: Thu Sep 30, 2010 1:11 am
by Christopher
The practical difference is that GET includes the parameter values in the URL. Post puts the parameter values in the body of the request.

http://en.wikipedia.org/wiki/Hypertext_ ... r_Protocol

Re: differences betweenGET andPOST

Posted: Thu Sep 30, 2010 8:37 am
by DigitalMind
use POST if you want your requests not to be cached

Re: differences betweenGET andPOST

Posted: Thu Sep 30, 2010 9:57 am
by AbraCadaver
GET should only be used to retrieve or "get" data. Use POST to send data that will result in a consequence (delete record, insert record, send email, etc.).

Re: differences betweenGET andPOST

Posted: Thu Sep 30, 2010 2:32 pm
by John Cartwright
Moved to PHP-Code.

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 2:22 am
by VladSun
DigitalMind wrote:use POST if you want your requests not to be cached
Well while it's true, it's not always true :)
GET caching is easily solved by adding an unique parameter to the GET request - like this:
[text]http://domain.com?param1=value1&param2= ... value_here}[/text]

the {unique_value_here} is usually the current time in milliseconds (an ever incrementing value, thus it's unique).

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 2:28 am
by VladSun
AbraCadaver wrote:GET should only be used to retrieve or "get" data. Use POST to send data that will result in a consequence (delete record, insert record, send email, etc.).
Just to elaborate - a GET request is vulnerable to CSRF thus a GET request should be used only and if only a pure "read" request is meant - i.e. no data changes required.

Another aspect of when to use a GET request can be found in RESTful services, though I'm not a big fan of it.

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 5:43 am
by DigitalMind
VladSun wrote:Well while it's true, it's not always true :)
GET caching is easily solved by adding an unique parameter to the GET request - like this:

Code: Select all

http://domain.com?param1=value1&param2=value2&....&__decache={unique_value_here}
the {unique_value_here} is usually the current time in milliseconds (an ever incrementing value, thus it's unique).
It's a very dirty solution and it doesn't mean your requests won't be cached. The cache will be cluttered up.

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 6:05 am
by VladSun
DigitalMind wrote:It's a very dirty solution and it doesn't mean your requests won't be cached. The cache will be cluttered up.
It's widely used by a lot of frameworks (ExtJS for sure) in order to solve cross browser caching issues. Just take a look.

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 6:10 am
by DigitalMind
Nobody told it won't work. In my opinion it's bad approach.

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 6:14 am
by VladSun
DigitalMind wrote:Nobody told it won't work. In my opinion it's bad approach.
In my opinion IE is just a tool needed to install a browser ;)

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 6:19 am
by DigitalMind
VladSun wrote:In my opinion IE is just a tool needed to install a browser ;)
Absolutely agree :D

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 2:19 pm
by VladSun
DigitalMind wrote:
VladSun wrote:In my opinion IE is just a tool needed to install a browser ;)
Absolutely agree :D
Ну договорились! :) [ OK, we've finally agreed :) ]

Re: differences betweenGET andPOST

Posted: Fri Oct 01, 2010 2:54 pm
by DigitalMind
Ага :) [Yup :)]