api pagination ai_generated partial

HTTP 400/404: Invalid cursor or pagination token expired

ID: api/rest-pagination-cursor-invalidation

Also available as: JSON · Markdown
68%Fix Rate
80%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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.

generic

Workarounds

  1. 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.
  2. 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
  3. 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:

  1. 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.

  2. Use offset/limit pagination to avoid cursor issues 78% fail

    Offset pagination skips items when rows are inserted/deleted between pages.