HTML and CSS Reference
In-Depth Information
Redirect POST to GET
Redesign scripts that respond to POST requests to redirect browsers rather than serving the results directly.
Code View:
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2008 20:58:58 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.0
Content-Length: 325
Content-Type: text/html; charset=UTF-8
<head><title>Order Accepted</title></head>
<h1>Invoice for your Records: Order #9878932479</h1>
<p>Please print a copy if you want to save it.</p>
HTTP/1.1 301 Moved Permanently
Date: Tue, 01 Jan 2008 22:39:42 GMT
Server: Apache/2
Connection: close
Content-Type: text/html; charset=UTF-8
It's convenient to be able to bookmark, link to, and return to orders, invoices, quiz results, and the like.
However, you can't do this with POST because the operation is unsafe. For example, bookmarking a POST
request to check out of a store might order the same items again when the bookmark was activated.
Instead, the server can respond to the initial POST by creating a new static resource for the order status.
Instead of returning the status directly, the server redirects the client to this new static resource. Then the
client can bookmark and return to that static resource whenever they like.
Potential Trade-offs
The server will need to save the results of POST requests for a reasonable period of time. They don't need to be
saved forever if they're not relevant indefinitely. (How many people check on an order six years after it's been
delivered anyway?)
Many of these results are at least somewhat private. You'll need to use the same level of authentication for
Search WWH ::

Custom Search