api
pagination
ai_generated
partial
HTTP 400/404: Invalid cursor or pagination token expired
ID: api/rest-pagination-cursor-invalidation
68%Fix Rate
80%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Many APIs invalidate pagination cursors after data mutations or after a time window (15min-1hr). Cursor-based pagination docs rarely mention this.
genericWorkarounds
-
85% success Complete pagination in a single session without long pauses
Process all pages in a tight loop. Store results locally, then process after pagination completes.
-
90% success Use keyset pagination (WHERE id > last_seen_id ORDER BY id)
SELECT * FROM items WHERE id > :last_id ORDER BY id LIMIT 100
-
88% success Implement checkpoint-based restart: store last processed item ID
On cursor expiry, restart pagination with filter to skip already-processed items
Dead Ends
Common approaches that don't work:
-
Cache cursor and resume pagination hours later
85% fail
Most API cursors expire within 15-60 minutes. Some (e.g., Elasticsearch scroll) expire in 1 minute by default.
-
Use offset/limit pagination to avoid cursor issues
78% fail
Offset pagination skips items when rows are inserted/deleted between pages.