Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Reconciling pagination with offline mode

Vicky Chijwani edited this page Dec 8, 2018 · 3 revisions

As #15 demonstrates, pagination becomes a non-trivial problem in the presence of offline mode and dynamic content. This page collects research and thoughts on solving this problem.

I have a sneaking suspicion that this can be framed as a classic CS problem with a well-known solution, but I haven't found a way to do that yet.

Resources

Constraints & capabilities

An ideal solution would have the following characteristics:

  • MUST NOT require modifications on the server side
  • MUST be correct
    • Posts MUST NOT be skipped in the pagination process
    • Posts created/edited/deleted offline MUST be handled correctly
    • Potential conflicts caused by simultaneous editing MUST be handled reasonably
    • Any given post appearing in the list MUST NOT be stale after a refresh
  • SHOULD minimize network usage; gzip compression can be assumed
    • SHOULD scale to large blogs of 10k+ posts - a refresh should take no more than a few hundred KBs

Here is what we get from the Ghost server:

  • Fetch all posts
  • Fetch a page of posts, defined by a tuple of (page num, limit)
  • Order posts using arbitrary fields before pagination
  • Filter the fields included in the response. This is useful because we can cache post contents separately from the list of posts, and for the latter fetch only post ids + updated_at timestamps (to determine ordering and freshness of content respectively), with a GET request to the following URL: /ghost/api/v0.1/posts/?fields=id,updated_at&...
Clone this wiki locally