How do I handle an api with server side pagination so the next page is loaded way ahead of time


Assume an api exists with server side pagination. You send page number in your request and it returns the 20 records relevant for that page - with thousands of pages.

A user rapidly clicks through hundreds of records and I’d like the user experience to be as smooth as possible.

If I wait until the user clicks on the last (20th) record from page 1 of results before requesting page 2 (and therefore the next 20 records) then there may be a delay as the data is returned.

Is there a recommended way to request pages ahead of time this way?