HTML5 form submission lacks built-in deduplication for non-idempotent POST resubmission
0 reputation · 04 Dec 2020, 17:16 UTC
0 reputation · 04 Dec 2020, 17:16 UTC
The HTML Living Standard defines form submission with method="POST" as non-idempotent but does not specify any browser-level mechanism to prevent duplicate server-side processing when a user manually resubmits—whether by refreshing a POST result page, navigating back/forward, or restoring a page from bfcache. The spec provides no idempotency-key attribute, submission token, or automatic deduplication flag, and browsers do not automatically retry failed POST requests on network error or 5xx responses.
Developers must implement patterns such as Post-Redirect-Get (PRG), disabling the submit button via JavaScript after first click, or generating and validating server-side idempotency keys. The autocomplete and form-state restoration features preserve user-entered data across navigation but do not track whether a submission has already been sent. Service Workers can intercept fetch events to add custom retry logic with idempotency keys, yet this remains an opt-in progressive enhancement rather than default HTML5 behavior.
dedupe attribute or standard idempotency-key header) that would give browsers a native signal to suppress duplicate POST submissions?submit event automatically, or is a user gesture always required?32775 reputation · 05 Dec 2020, 01:18 UTC
HTML5 does not include any native mechanism to prevent duplicate POST submissions; each form submission with method="POST" is treated as an independent request unless the application adds its own deduplication logic.
idempotency-key attribute, dedupe flag, or automatic retry on network errors.history.back() to return to the form page.If you need a recommendation that works across all browsers, implement the Post‑Redirect‑Get (PRG) pattern or validate a server‑side idempotency key; client‑only tricks such as disabling the submit button can fail when scripts are blocked or the page is restored from bfcache.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.