Pagination exists so that a whole list is not sent in one response. An offset says "skip this many rows, then return this many". That works while the list is still. When a row is inserted in between, the offset slides. The second page repeats the last row of the first, or it never sees the row that was inserted. The user reads that as a missing record.
A cursor carries the identity or the sort value of the last row seen. The next request asks for "what comes after this". A row inserted in between does not make the previous page repeat. The inside of the cursor stays closed to the client. If the client tampers with it, the server rejects it. If the sort changes, the cursor changes. A cursor built for a name sort is not applied to a list sorted by date.
RFC 8288 defines carrying links in the Link header. rel=next gives the address of the next page. The client does not assemble the address itself. If the address changes, the header changes and the client code does not. If rel=prev is present, the previous page is in the same header. Without the header, the client looks at a field in the body. If the two name different addresses, the contract is broken.
Page size is capped. If the client asks for a size above the server's limit, the server applies its own limit and writes the size it applied in the response. If the limit is not written, the client reads a short page as the end of the list.
On a FenergyTech endpoint that returns a list, the cursor and the Link header are given together. Offset is left only for a report whose list stays still.
The slide of an offset shows up as one row. The page size is 50. The client takes the first 50. A row is inserted at the head of the list in between. The second request says offset=50. The last row of the first page comes back at the head of the second. The inserted row is never seen. A cursor carries the sort value of the last row seen. The next request asks for what comes after it. A row inserted in between does not repeat the previous page.
The inside of the cursor is closed to the client. If the client tampers with it, the server rejects it. If the sort changes, the cursor changes. A cursor built for a name sort is not applied to a list sorted by date.
RFC 8288 carries the address of the next page in the Link header, rel=next. The client does not assemble the address. If the address changes, the header changes. If the body also names an address and the two differ, the contract is broken. Page size is capped. If the client asks for 1000 and the server returns 100, the response writes the size it applied. If it does not, the client reads a short page as the end of the list.
Sources: RFC 8288, Web Linking, IETF, 2017. RFC 9110, HTTP Semantics, IETF, 2022.
Planning a similar project?
We can talk through how the topic in this article applies to your product.