Monday, November 10, 2008

idempotent request and non-idempotent request - in HttpServletResquest Header

Official definition from dictionary.com is "unchanged when multiplied by itself". In HTTP perspective, you can send idempotent requests multiple times without altering system state / data / resource.

Since get requests are meant to get required resource and not change anything, it's considered idempotent. Although technically it's feasible to implement your program in bad way that would alter the data even for get request.

Post request are usually implemented to achieve server side action that would alter data. For example, providing your credit card and submitting purchase button. If you submit the button twice, chances are that you might pay twice! Since post requests are non-idempotent, one should take extra care in implementing it such that duplicate request doesn't go through.

No comments: