Idempotency keys — mandatory для money-movement, cheap insurance elsewhere. Client dedupe ≠ server idempotency.
Разбор
- Idempotency keys mandatory для money-movement и resource-creation, cheap insurance elsewhere. Cost — stateful store (Redis/DB) keyed by key с TTL — small price vs double charge.
- Client dedupe ≠ server idempotency. Coalescing in-flight promises stops double-submit с one page; nothing для retry after lost response, reload, two devices. Real side effects — server-side only.
- Prefer idempotent method semantics.
PUT /transfers/{clientGeneratedId} — idempotency free, resource ID is key.
- Keys genuinely unique, stored long enough (Stripe 24h). Short TTL — late retry re-executes; reuse key across operations — wrong cached result.
Итог
Server-side idempotency store с TTL — price of safety; client dedupe — UX layer, не substitute для payments и creates.