GET – Requests data from a specified resource
Note that the query string (name/value pairs) is sent in the URL of a GET request:
/test/someURL?name1=value1&name2=value2
Some other notes on GET requests:
- GET requests can be cached. As in the URL with the query string will be cached in your browser.
- GET requests remain in the browser history
- GET requests can be bookmarked
- GET requests should never be used when dealing with sensitive data, because the data is displayed in the URL via the query string
- GET requests have length restrictions. As of 7/2015, most webservers have a limit of 8192 bytes (8KB), which is usually configureable somewhere in the server configuration.
- GET requests should be used only to retrieve data
A GET should not have a body, so aside from cookies, the only place to pass info is in the URL.
POST – Submits data to be processed to a specified resource
The POST Method
Note that the query string (name/value pairs) is sent in the HTTP message body of a POST request:
POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
Some other notes on POST requests:
- POST requests are never cached
- POST requests do not remain in the browser history
- POST requests cannot be bookmarked
- POST requests have no restrictions on data length
Besides keeping the URL relatively cleaner, POST also lets you send much more information (as URLs are limited in length, for all practical purposes), and lets you send just about any type of data (file upload forms, for example, can’t use GET — they have to use POST plus a special content type/encoding).