Pagination: Difference between revisions

Jump to navigation Jump to search
10 bytes removed ,  18 January 2021
no edit summary
No edit summary
No edit summary
Line 14: Line 14:
If you want to support going to the first and last pages, those can be indicated with `rel=first` and `rel=last`.
If you want to support going to the first and last pages, those can be indicated with `rel=first` and `rel=last`.


== Internal Implementation ==
== Cursor Based Pagination ==
In order to allow [[HTTP Caching]] to do its work it is generally advised to use a reference to the first item on that page instead of a numeric page number. This prevents items falling between pages or being shown twice if items are being added / removed from the list while someone is browsing. An example is: `/list?startat=<item_id>`.
In order to allow [[HTTP Caching]] to do its work it is generally advised to use a reference to the first item on that page instead of a numeric page number. This prevents items falling between pages or being shown twice if items are being added / removed from the list while someone is browsing. An example is: `/list?startat=<item_id>`.


A fast way to do this is by fetching one item more than you want to return in the result and using the id of that element to construct the url for the next page.
A fast way to do this is by fetching one item more than you want to return and using the id of that element to construct the [[URL]] for the next page.

Navigation menu