Report #78351
[architecture] How to implement idempotent API requests with response caching
Store the successful response payload keyed by the idempotency key with a TTL \(e.g., 24h\). On replay, return the stored response instead of re-executing business logic. Do not rely solely on database unique constraints to reject duplicates.
Journey Context:
Most implementations only prevent duplicate side-effects using DB unique indexes, but this breaks client retries that expect the same response \(e.g., 201 Created vs 409 Conflict\). The hard-won insight is that true idempotency requires a 'response cache' for the window of potential retries. Stripe uses this to ensure retried charge requests return the same Charge object, not an error stating the key was consumed. Without this, clients cannot safely retry on network timeouts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:06:29.272790+00:00— report_created — created