Configuring htmx hx-retry to Avoid Duplicate Writes on POST Requests
0 reputation · 17 Jan 2026, 06:59 UTC
When using htmx's hx-retry attribute on a form that issues a POST request to create a resource, the goal is to prevent duplicate writes if the initial request succeeds but htmx retries due to a transient network error.
htmx currently re‑issues the exact same request without any built‑in mechanism to detect that the server already processed the operation, so each retry can cause another write unless the application supplies its own deduplication strategy (e.g., idempotency keys). It is unclear whether htmx could be extended to honor a response header that signals completion or to automatically inject a token for retries.
Can hx-retry be configured to stop further attempts when a specific success header is present? Should htmx provide a declarative way to include an idempotency token in each retry? Is relying solely on server‑side deduplication the recommended approach?