I am working with a REST API that utilizes server-side pagination to return data consisting of items like ID and name. Additionally, there is a 'nextToken' provided which acts as a cursor for navigating through the data.
{
items: [
{
id: 1,
name: 1
},
{
id: 2,
name: 2
}
],
nextToken: <some-hash-key> // cursor-based
}
Now, the challenge is how the client application should refresh its list in case the resource gets updated without the client being informed (a pull model situation). I have come up with a couple of ideas:
- Periodically fetch all resources, say every 10 seconds.
- Maintain a session ID that changes every N minutes. Upon creating a new session, retrieve all resources.
Both these approaches share a common core concept but differ in their implementation nuances. The first option incurs higher costs but provides more real-time updates while the second one relies on session IDs, offering a more idiomatic solution albeit sacrificing real-time updates. Are there any alternate approaches worth considering?