skip to content

In a mobile news app's infinite feed, how do you size a page and decide how far from the end to request the next one?

level: middleimportance: must knowfreq 62%

answer

  1. rows per screen, not a magic number
  2. ask before the end, not at it
  3. distance covers speed times slow latency
  4. page size sets how often you ask
  5. label every input as an assumption

basics

~20 s

Derive both from the screen and the link: the prefetch distance must cover the rows a reader scrolls during a slow page request, and a page should span several screens so requests stay infrequent. Express both in screens, not fixed rows.

solid answer

~50 s

I work from stated assumptions: a phone shows about four article cards, a commuter skims about one card a second, and a slow page request on a train takes about three seconds. The next request has to start at least speed times latency before the end, three cards, so I set the prefetch distance to two screens, eight cards, to absorb a short fling. Page size sets how often the app asks: twenty cards, five screens, means one request per twenty seconds of skimming, so at reading pace a new request is not due before the last one lands. I express both in screens so a tablet scales up, keep the page within the limit the API accepts, and raise the distance when measured latency grows. No standard number exists; these come from the scenario.

go deeper

for a junior

Recall that the next page is requested some rows before the end, and that both page size and that distance come from the screen and the network, not from a fixed number.

for a middle

Work the numbers aloud: rows per screen, scroll speed and slow-end latency, then a distance and a page several times larger, labelling each input as an assumption.

for a senior

Show the design adapting: measured latency feeding the distance, sizes in screens for tablets, the API's cap, and the waiting you accept during a fast fling.

for a principal

Weigh one tunable paging policy shared by all the app's feeds against per-surface values, and how field measurements of waits at the bottom would drive the tuning.

## Two numbers, two jobs A paged feed has two knobs that are easy to blur together. **Page size** is how many items one request asks for. **Prefetch distance** is how many unread rows remain below the viewport when the app starts the next request. They answer different questions: | | Page size | Prefetch distance | |---|---|---| | Controls | How often the app asks | How early it asks | | Too small | A request every few seconds of reading; requests can pile up behind a slow link | The reader reaches the bottom and waits on a loading row | | Too large | Each response is slower to arrive and parse; more data fetched that may never be read | Pages fetched for readers who were about to leave | | Derived from | Rows per screen and how long one request should last | Scroll speed times the slow end of request latency | No figure in any platform guide or protocol gives a "right" value for either. Both are derived from the scenario, and a good answer labels each input as an assumption. ## Working the numbers Take a news app read on commutes. Assumptions, stated as such: 1. **Rows per screen:** a phone shows about **4** article cards (headline, publisher, a thumbnail). 2. **Reading speed:** a commuter skimming headlines moves about **1 card per second**; a fling can briefly reach **8 cards per second**. 3. **Latency:** a page request on cellular in a moving train takes about **0.8 s** typically and **3 s** at the slow end. Now derive: - **Minimum prefetch distance** = speed x slow latency = 1 card/s x 3 s = **3 cards**. Below that, a steady reader catches the loading row on a slow request. - **Chosen prefetch distance** = **2 screens = 8 cards**. The margin absorbs a short fling and a slower-than-usual request. - **Page size** = **5 screens = 20 cards**. At 1 card per second the reader consumes a page in about 20 s, so requests stay far apart, and 20 cards is much more than the 3 cards read during one slow request, so at skimming pace a new request is not due while the previous one is still out. - **The fling case:** at 8 cards/s, 8 cards of distance hide only 1 s of a 3 s request. The reader sees the loading row for about two seconds. That is an accepted cost; covering every fling would fetch pages most readers never reach. The general rule is the inequality behind the arithmetic: distance >= speed x latency, and page size comfortably larger than the rows read during one request. ## Screens, tablets and the link - **Size in screens, not rows.** A tablet showing 10 cards per screen needs a distance of 20 cards and pages of about 50 to keep the same behaviour; the same 8-card distance would be less than one tablet screen. - **Respect the contract's limit.** The API usually caps the page size. If the cap is below what the arithmetic wants, keep the cap and start the request earlier instead. - **Use measured latency, not the connection label.** A rolling slow-end figure from the last few page requests is a better input than the connection type; a nominally fast link in a moving train can be slow. - **Adapt the distance first.** When latency rises, a larger distance hides it without making each response slower; a larger page cuts the number of round trips but delays each arrival. - **The first network page** has to fill the screen plus the prefetch distance. Some designs ask for a larger first page; with a feed persisted on disk, a relaunch paints from the store and the first request only extends it. ## Where the trigger comes from The trigger is "the last visible row index is within N rows of the last loaded row". Every list component can report the visible range; which callback reports it is a framework detail. What matters for the design is that the trigger fires often near the end, so the code that acts on it needs a guard against requesting the same page twice; that guard is a separate decision about load state. ## Common mistakes - Starting the request when the last row appears: the reader then always waits for at least one full request. - Copying a page size from another app or a library default and calling it standard. - One row count for phone and tablet. - A huge prefetch distance "so nobody ever waits", which fetches pages for readers who leave after two screens; what that costs in data and battery is a question for the device's radio and data budget, not for the paging design.

  • A reader flings at eight cards a second during a three-second request. What happens with your numbers, and is that acceptable?
    The eight-card distance hides only about one second of the request, so the reader reaches the bottom and sees the loading row for roughly two seconds before the page lands. That is acceptable: flings are short and followed by slower reading. Raising the distance to cover every fling would fetch pages that most commuters, who read a few screens and leave, never reach.
  • How does the app decide the link has become slow enough to change the prefetch distance?
    By measuring rather than guessing: keep the slow end of the last several page-request durations and the reader's recent scroll speed, and recompute the distance from them. The connection type is a weak proxy, since a nominally fast link on a moving train can be slower than a good slow one. Whether deeper prefetch is worth its data and battery cost is a separate budgeting decision.
  • The API caps pages at 10 items, below the 20 your arithmetic wants. What changes?
    Keep 10 and compensate with timing: the reader now consumes a page in about ten seconds, still well above the three cards read during a slow request, so requests do not pile up. Keep the prefetch distance at eight cards or more, and accept roughly twice as many requests. Asking for more than the cap usually just gets clamped or rejected.

Like a reader of a long printed newspaper who turns to the next spread while a few columns remain on the current one: how many columns ahead depends on how fast they read and how long the page takes to turn.

  • Requesting the next page when the last row appears hides the network delay.
  • There is a standard right page size, such as 20, for every feed.
  • A bigger prefetch distance is always better because nobody ever waits.
  • The same row counts work on a phone and on a tablet.
  • The prefetch distance can stay fixed whatever the measured request latency.