I'm building an ajax application and I have a choice to make on how to structure a data paging functionality. Basically, the user is going to work with 1,000 - 2,000 records but only 20 records are loaded simultaneously from the DB, sent to the client, and then cached in the local session storage. These records are json strings that contain an object's property (basically, a customer record).
Here are the two choices, let's assume we're working with 1,500 records and that each page is 20 records long. The dilemma is where to store the 1,500 IDs of the records.
Option 1: The IDs of the 1,500 records are stored as a list of int on the server session, and serialized and deserialized for each request. The client is unaware of the record IDs of each page and just requests a page number. On the server, when the user requests page X, we look at the list of int and determine the IDs of the records for page X, load those records and send the client the json strings with these IDs. The downside here is that we're carrying a list of 1,500 ints on the server session. The upside is that when we're requesting a page, we're only sending the server an int.
Option 2: The IDs of the 1,500 records are sent to the client when the user logs in and then that list is stored in the local storage session. When the user requests page X, a javascript function determines which record IDs are on page X and sends the server a json serialized list of 20 ints. The server then returns the records with those IDs. The upside is that the server side session is much lighter and that should increase performance (no need to read/write/serialize that list at every request) and probably more scalable. The downside is that we're sending the server a list of 20 ints every time we're requesting a page.
I'm leaning for option 2: is this the best way to do it?
Note 1) that I'm requiring users to support HTML5 local storage and 2) the server-side implementation will be azure and WCF.