[Previous] [Contents] [Next]


GET versus POST


Both the GET and POST methods send data to the server, but which method should you use?

The HTTP standard includes the two methods to achieve different goals. The POST method was intended to create a resource. The contents of the resource would be encoded into the body of the HTTP request. For example, an order <form> might be processed and a new row in a database created.

The GET method is used when a request has no side effects such as performing a search, and the POST method is used when a request has side effects such as adding a new row to a database. A more practical issue is that the GET method may result in long URLs, and may even exceed some browser and server limits on URL length.

Use the POST method if any of the following are true:

  • The result of the request has persistent side effects such as adding a new database row.

  • If the data collected on the form is likely to result in a large URL if implemented using the GET method.

  • The data to be sent is in any encoding other than seven-bit ASCII.

Use the GET method if all the following are true:

  • If the request is essentially finding a resource, and HTML <form> data is to help that search.

  • The result of the request has no persistent side effects.

  • If the data collected and the input field names in a HTML <form> are less than 1,024 characters in length.


[Previous] [Contents] [Next]