title: How to ensure data consistency in REST API pagination
body: <p>I'm building an instant messenger on mobile client that interacts with RESTful API through HTTP requests. The pagination endpoint is quite standard - it has starting location (offset) and number of items in a page (limit). I'm having trouble figuring out how to ensure 100% data consistency with pagination when the database can rapidly change. </p>
  
  <p>For example, with some dozen participants, there could be a dozen new messages in a conversation within a second. I don't think it's far-fetched to guess that some of those messages can alter the database within the time the HTTP request for pagination comes back from the server. Fortunately, since this is a messenger I do not have to consider the possibility of data deletion and consider only the data addition.</p>
  
  <p>Among my research, following two links were quite helpful but didn't provide clear solution: </p>
  
  <p><a href="https://stackoverflow.com/questions/15244320/how-to-ensure-data-integrity-in-paginated-rest-api">How to ensure data integrity in paginated REST API?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/8487283/how-to-implement-robust-pagination-with-a-restful-api-when-the-resultset-can-cha">How to implement robust pagination with a RESTful API when the resultset can change?</a></p>
  
  <p>The only potential solution I can come up with is using the timestamp of the last object in the previously fetched page. So the HTTP query would have timestamp as a parameter, and the server would return a page of objects created after that timestamp. </p>
  
  <p>Is there any potential problem I'm not seeing, or even better, a much better solution to this issue?</p>