When to Use Form POST vs GET?
I think I (unintentionally) offended Mark with my comment where I asked why would anyone EVER use GET? because I pretty much always use POST so was wondering why you would use GET.
In my search for answers I asked Mark Lynch who seems to always have the answer to my questions :)
So in summary (from Michael Schwarz);
- By default no proxy server or web browser is caching this data, you will always get the real data from you web server.
- The length of data you can send to the web server is only restricted by the web server itself, but there is no real restriction.
- Character encoding can be done easily using application/x-www-form-urlencoded.
- Running a http request with GET can be cached on your web browser or a configured proxy server.
- To get the live data from you web server you have to modify the url that is used in your XHR invoke, simply by using a counter or new Date().getTime() which will generate a unique url.
- Maximum URL length is 2,083 characters in Internet Explorer (see MaxClientRequestBuffer: Use POST instead of GET to Send Large Amounts of Data in Request)
- In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. [RFC 2616 sec 9]
- Character encoding will reduce the amount of data that can be used because of url encoding entities (i.e. three Japanese characters are converted to this: %26%2312454%3B%26%2312455%3B%26%2312502%3B)
There is also a great article here if you want some further reading on this subject.
For me (at this stage) this really only has an effect when doing Ajax. If I’m purely wanting to retrieve data (just HTML for example) from the server then I’ll use GET, but if I want to do something else with server side effects (such as posting data to be saved to a database) then I’ll use POST.
Phew…you learn something new everyday!