CodePark/ questions / Pagination, filtering & versioning
START PRACTICINGPRACTICE
Backend question · HTTP & API design › Pagination, filtering & versioning

A client reads page 1 of GET /posts?sort=-createdAt&limit=10&offset=0. Before it requests offset=10, three new posts are published. What does page 2 show?

Three posts it already saw on page 1, then 7 new-to-it posts

The answer is "Three posts it already saw on page 1, then 7 new-to-it posts". The three new posts push every older post down by three positions. So offset 10 now starts at what used to be position 7. The last three posts from page 1 appear again.

"Exactly the next 10 posts, with no overlap" would be true only if the data did not change. Cursor pagination avoids this problem: it asks for items after the last sort key the client saw.