• caglararli@hotmail.com
  • 05386281520

Server pagination with key in response to fetch next page

Çağlar Arlı      -    14 Views

Server pagination with key in response to fetch next page

I want to introduce pagination in one of my server endpoints.

The endpoint will have an option to include in the parameter the last index of the previous page, and if included, the "page" returned will start from the first index bigger than the last index.

e.g, if the last item in the page returned is 222, the last index parameter will be 222, and the server will return items starting from 223.

The problem is that I also want to have caching on my queries (the pages should be static).

Currently, submitting the last index in plain is bad, as the user can modify the value and hence bypass the caching every time.

I want to return in the response of the page, a signed last index, which the user could add to the url to fetch the next page.

But I already have user authentication using JWT token, and I don't want to have another token in the url just for pagination.

Is there a better alternative to JWT to sign a small field so the server will be able to discard invalid values?

The server mentioned is Spring boot with Spring Security included.