What is server and client side pagination?
Server side pagination, where the pagination script calculates the number of records in the database and then makes links? All I know is that the server side is faster and better if there is a lot of data and the client side uses javascript?
What does a page server script do on the server or client side?
Also, I am currently planning on using this pagination , which is similar to digg-style. Can anyone tell me if this is pagination? (sorry if my terminology is off)
a source to share
The client side is when you pull all the data down and then the client segments the data in the pages.
The server side is usually performed by the client providing the key, which is passed to the server, and then the server fetches that "page" of data. For example, if you were showing people by last name, the first page could be created telling the server that you want people with the last name "A" and that you need to return 10 lines.
The server will do something like:
SELECT ssn, fname, lname
FROM people
WHERE lname like 'a%' and rownum <= 10 ORDER BY lname, ssn;
If the last / 10th entry has the last name "abbot" with SSN 555555555, the next page can be received by the client passing these values back to the server, which then does something like:
SELECT ssn, fname, lname
FROM people
WHERE lname >= 'abbot' and ssn > 555555555 and rownum <= 10 ORDER BY lname, ssn;
The server side is considered better for large datasets because the amount of data transferred to the client is much less than if all the data is flushed and "offloaded" by the client. It also reduces the amount of memory required on the client side, and also takes advantage of the powerful capabilities of databases to sort data or leverage existing sorted indexes to speed up selections.
a source to share
Server side pagination:
The server accepts several parameters from the user (current page #, order, etc.) and performs whatever lookup it needs to get only matching records. They are sent to the client along with links to other pages, etc.
Every time the user clicks on the link, you get a page refresh showing new data.
Useful when:
- many results or the payload for each result is quite large
- searching / processing results takes a long time
- users rarely view the first page
Not so great because:
- Each click is a round trip to the server, which can take some time
- Maintaining health is PITA
Client page breakdown:
The server sends all available records to the client and uses Javascript, these results are paginated and displayed on the client side. Changing pages or reordering positions is as fast as instant and does not require server interaction. This makes it much easier to cache the results on the server side.
Useful when:
- Not many results (just a few pages)
- Users will be using many pages (so sending additional data is not a waste)
- Form splitting: Since each login page is simply hidden and not deleted, the entire form can be submitted in one form.
Not so great because:
- The initial page load is much larger
- May be a problem for users without JS (although graceful degradation is quite possible).
- You may need to duplicate display logic in Javascript.
Mixed approach
Write your application to make full use of server side pagination. Once this works, use javascript to intercept all links that change the page or order and send those requests via AJAX. Adapt the server side script to only return the HTML needed for any page, and none of the chrome pages around it when it responds to an AJAX request.
Benefits:
- Minimum payload per page turn = faster response times.
- Fully scalable.
- It completely degrades.
a source to share