Forum Moderators: open

Message Too Old, No Replies

refresh resends POST data [revisited]

sometimes called the double post problem

         

geekpie

6:09 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



I understand that all the major browsers resend POST data when a page reached by a POST request is refreshed.

I'm interested to know the mechanics of this. It seems to imply that the message body of the POST request (which contains the POST data) is stored somewhere during that session: the evidence of this is that one can browse further, return to the page reached via the POST request, Refresh, and somehow the browser has flagged that it was fetched by a POST request. It can't know that it was a POST request from the URL alone: it's remembered somehow. How?

BlobFisk

12:56 pm on Jul 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi geekpie and welcome to WebmasterWorld.

This is a problem with the way forms are handled. The browser caches the data that you sent and if you refresh the page it will try to re-POST that data.

The way around this is to use a POST-redirect-GET. Here the backend receives the POST data and redirects to the page which GETS the data so that the refresh doesn't cause this issue.