I need to prevent duplicate form submissions for my customer's website.
- we need some form data from user for order confirm page.
- we use load balancing for web server.
Approach 1 : Post/Redirect/Get
(PRG pattern : http://en.wikipedia.org/wiki/Post/Redirect/Get)
I was trying to use PRG pattern at first.
in this case, I think I need to deal with session(or spring flashmap) across multiple web server.
Approach 2 : Disable refresh on client.
one of my colleague suggested this approach.
Approach 3 : Post/Post
another colleague suggested this approach.
I think approach 2, 3 is not a good choice.
but I do not know the specific cons or security risk about these approaches.
I tried to google, but I failed to find answer.
Thank you in advance.
[Edit]
I would like to update the pros and cons.
Approach 1 : Post/Redirect/Get
pros
- Safe!
cons
- if you need some form data from user to show it on confirm page, you need to use
session
,database
or something. - if you use
session
, and have more than one server, you have to do something to make session available across multiple servers.
Approach 2 : Disable refresh on client.
pros
cons
- Users will get upset if you limit the browser standard features, like refresh.
- need to consider F5, Ctrl+F5, ⌘ + F5 etc, various refresh icons.
- In mobile, many web browser automatically refresh page when user reload browser.
Approach 3 : Post/Post
pros
- You don't have to worry about session sharing issue across multiple servers.
cons
- Second form submit can fail.