How to handle obsolete data in REST?

For example, if I call GET to get an element, delete it with DELETE and again GET, how should the second GET work?

I mean, following REST principles correctly, what is the right approach to this, since GET can be cached and that's it? What is the approach to processing obsolete data in REST?

+7
source share
2 answers

First of all, the behavior depends on which DELETE call was returned as the response code.

If DELETE returns 200 - OK or 204 - No Content , then the client should receive 404 - Not Found on the next GET call. This is because 202 and 204 mean that the resource was deleted immediately.

However, if DELETE returns 202 - Accepted , there is a possibility that the client will be able to successfully GET the resource for some time. This is because 202 means that the resource has been marked for deletion, but is not necessarily cleared immediately.

Secondly, if there is a cache, the behavior should be built so that it matches what would happen if there were no cache. A successful DELETE should always result in deletion as from the true origin of the data in addition to any cached copies.

+4
source

As originally stated, GET after DELETE should cause an HTTP 404 error, regardless of the caching that may be in place. Logical code must be smart enough to remove a record from persistent storage, as well as storage or cache in memory. In addition, the user interface should be able to process the result 404 with any thread or process that you think is appropriate.

0
source

All Articles