Previous page data refresh | System Design | iOS

Shrawan K Sharma
2 min readJun 15, 2023

The problem statement is as follows:

Consider scrolling to the fifth page, and we see that the first page’s data has been updated in server. What should we do about it?

Functional requirements:-
- Refresh paginated data

Non-functional requirements:-
- Battery optimization
- Smooth transition
- Network load

Refresh paginated data

We can use the 6 techniques to refresh our first page

  • When calling 3rd page API, just call 1st & 2nd page api’s in parallel. This is the most destructive thing we can do, calling every previous page API’s on the next page. Both the server and the frontend will suffer the worst performance impact.
  • The server should keep track of feed data for each user. The user will be notified if any feed data has been updated. Here the challenge is the server needs to keep track of user feed data, which will overload the server. The server needs to notify the end user, and the API must be called.
  • With each API call, the client sends the previous feedID’s/commentID’s and timestamp along with the next page request. This allows the server to check the last updated timestamp of previous feedID’s/commentID’s. Backend will return updated feed data if there are any updates to feed data. Backend cache of the end user must contain updates to feeds.
  • Heartbeat to the server. After a certain period, client asks server to check the previous feed data. It will increase API hits and most of the time, will result in an empty response.
  • In use case of twitter feed/homepage, we can consider only celebrity and famous pages. We will ignore all other updates to the previous feed data except for celebrities and famous pages. Server will check celebrity and famous pages of previous pages and send updated data.
  • Server side events (SSE) can be used if there is a low chance of updating the feed. Clients receive events from the server. Similarly, in the Calendar use case, the end user is notified if there are updates to the event on the server.

--

--

Shrawan K Sharma

iOS App Developer - Frontend(ReactJS) - Building innovative products - MNNIT