Hacker News new | ask | show | jobs
by ezekg 2661 days ago
I like how Stripe does idempotent requests [0]. Essentially, you end up saying, "do this thing, which I'm calling 'charge-for-cust-foo', but only do it once, even if I tell you to do it again." Putting the "burden" of generating a unique idempotency key on the client seems to be the best solution, otherwise, they have to somehow store the idempotency key that your service generates to re-send it for the next request, which adds complexity on their end, especially when the request could be sent from multiple servers that need to share which key belongs to which request (i.e. multiple servers rule out storing the keys in memory, which would already pose a risk due to crashes/restarts clearing memory).

[0]: https://stripe.com/docs/api/idempotent_requests