Starting Point:
According to https://www.rfc-editor.org/rfc/rfc9110.html#name-safe-methods, when making a GET call, the client is not requesting and not expecting the call to lead to any state changes.
Request methods are considered "safe" if their defined semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource.
Of the request methods defined by this specification, the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
In my understanding, the following application violates the spec, because current-value
is in the DB state of /objects-with-value/1
and changes with each call.
GET /objects-with-value/1
{
"id": 1,
"local-variables": {...}
"current-value": 123.0
}
where
current-value
depends onlocal-variables
and also depends on the current day, and is the result of a call to an external servicecurrent-value
is persisted in the DB state of/objects-with-value/1
Question:
My assumption is that an application which does not violate the above mentioned RFC would rather look like this:
current-value
is not in the DB state of/objects-with-value/1
- instead, it is calculated on each
GET
call - the external call is cached
The assumption is only correct if the population of the cache is not considered a state change. Hence, the question: Is caching external calls considered a state change in the context of safe HTTP methods?