[Melbourne-pm] a fix for the back-button causes re-submit problem

David Dick ddick at aapt.net.au
Mon Jan 29 02:50:42 PST 2007

quick note.  have been having issues for a while with how best to solve 
the issue of the users adding a new object to the database via a web 
front end and then for some reason, deciding to hit the back button and 
accidentally add the object a second time. 

i've recently read about using a 303 to redirect from the POST add url 
to a GET /object?id=newid type url. So the request/response cycle goes like;

client clicks the 'save new object button and sends a

POST /script/name HTTP/1.1

after validation, new_id gets created on the server, so the server 
redirects the user to access the newly created object via a GET

Status: 303 See Other
Location: /script/name?Id=newid

the client "forgets" about the POST step, replaces it in the history 
list with the redirect and issues

GET /script/name?Id=newid

which if the user clicks the backbutton from where-ever to where-ever it 
should have no effect, unless the user deliberately clicks the save 
button again.

i seem to be having a lot of success with this "trick" with a test 
application, but was wondering if anyone else is doing this and if there 
is anything that could cause dramas, such as MSIE version X that refuses 
to co-operate, etc.


More information about the Melbourne-pm mailing list