Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On the idempotence of GET

Tags:

idempotent

get

I have been doing some reading on the GET HTTP method and in particular on its idempotent quality.

This is my understanding: if I call a GET operation 1 time or a million times (or any number of times) the result should be the same.

My problem with this definition is this.
Imagine if I have a database of films and I perform a GET operation in which I return all the James Bond films in the database.
Imagine I run this query a million times and after the 500,000th time someone else runs a POST query on the database adding a new Bond film.
Well, now half the GET operations return N results and the other half return N+1 results.

Does this not then break idempotence as it is usually described?
Would not a better definition be that the idempotence of a function is that it returns the same results no matter how many times it is executed as long as the underlying data does not change?

like image 466
Sachin Kainth Avatar asked Oct 05 '12 19:10

Sachin Kainth


2 Answers

GET idempotent because it does not (or should not) change the resource. This does not require that the resource is static and nothing else (like a post) never changes it.

like image 86
Ray Avatar answered Oct 04 '22 05:10

Ray


The idempotence is about the fact that the GET calls do not change the resource being called.

What other methods do is a different matter.

like image 27
Oded Avatar answered Oct 04 '22 06:10

Oded