Here is what’s happening in my RESTful web app:
- HTTP request comes in
- The app starts to build a response, with some initial portion of data
- Another requests changes the data that where used in step 2
- The first request understands that the data are expired
What should it do? Fail the request and return an error to a client? Or it should start from scratch (taking more time than the client expects)?
Assuming it not about db transactions and say distributed long running processes are involved in each step.
In this scenario the client should be sent an appropriate response (something like 409/410 http codes) with details indicating that this request is no more valid and the client should try again. Retrying could end up in loops or worst case end up doing what client did not know.
Example, when you book a hotel/ticket online you get a response saying the price has since changed and you need to submit again to buy with new price.