I have a REST API that implements server-side pagination returning the following data:
{
items: [
{
id: 1,
name: 1
},
{
id: 2,
name: 2
}
],
nextToken: <some-hash-key> // cursor-based
}
How should the client application refresh the list if the resource gets updated (client isn’t aware of the update, so this is a pull model)? I have some ideas:
- fetch all resources at a regular interval (like every 10 seconds)
- maintain a session ID that rotates every N minutes. When a new session is created, fetch all resources
Both approaches are fundamentally the same idea. The first approach is more costly but allows more real-time updates. The second approach is based on session ID which I think is more idiomatic, but no real-time updates. Is there any other approach?