This is a problem that I have been thinking about for a long time, but have not written code yet, because first I want to solve some common problems that I am struggling with. This is the main thing.
Background
A one-page web application makes data requests to some remote API (which is under our control). Then it stores this data in the local cache and serves the pages from there. Ideally, the application remains fully operational with offline access, including the ability to create new objects.
Limitations
- Suppose a server-side database of products containing + 50,000 products (50 MB)
- Suppose there is no db type, we interact with it through the REST / GraphQL interface
- Suppose a single product record is <1kB
- Suppose the maximum payload for a result set is 256 KB
- Assume a maximum storage of 5 MB per client
- Suppose a set of search results is in the range from 0 to 5000 items per search
Call
The task is to determine an effective way without taking into account the state, but (network), to extract pages from the result set to determine what results we will get.
Example
In traditional paging, when you receive the following 100 results for some query using this URL:
https:
The search result may look like this:
{
"totalResults": 2458,
"firstResult": 100,
"pageSize": 100,
"results": [
{"some": "item"},
{"some": "other item"},
// 98 more ...
]
}
, , . , , (- ), , . : , , 0 , , .
, , , - 2458 , ( , )
, "pages", . , , , . , . , , ... .
, , - ... , , SELECT * FROM products WHERE id IN (3,4,6,9,...)... ...
, . - , , . , , , .