Skip to content
Preptima
mediumDesignConceptMidSeniorStaff

Clients are asking for page 4,000 of your /orders collection. How is that endpoint paginated, and what would you change?

5 min readUpdated 2026-08-15

Answer

Short answer

Offset pagination gets slower with depth and drifts when rows are inserted mid-traversal, so paginate with a keyset comparison on the sort key plus a unique tiebreaker, hand back an opaque cursor and a Link rel=next header, and price an exact total count separately.

Pagination is still an HTTP contract. Good HTTP pagination defines stable ordering, opaque cursors, cache behaviour, and error responses when a cursor is stale or invalid. Weak HTTP designs expose database offsets and let concurrent writes reshuffle results. Strong HTTP pagination treats the cursor as part of the API contract, not as a leaked query parameter.

Was this answer helpful?

Likely follow-ups

  • The client wants to sort by any column it likes and still use cursors. What do you tell it?
  • How do you paginate a result set assembled from two different services?
  • A cursor issued three weeks ago is replayed. What should happen?
  • Where does an ETag or Cache-Control fit on a paginated collection, if anywhere?

Related questions

Masterclass guide

Further reading