Learn how to a build a cloud-first strategyRegister Now


custom paging a datagrid and caching

Posted on 2006-04-16
Medium Priority
Last Modified: 2008-03-10

I use the term custom paging to refer to the process of retrieving database records one page at a time rather than all in one go.

I have seen caching implemented with datagrids that use default paging (get all the records in one go). Is there any point/benefit from implementing caching with custom paging? How would you implement caching with custom paging?

Thanks very much

Question by:andieje
  • 2

Expert Comment

ID: 16466522
It depends.

The project that I'm working on at the moment can be connected to one of four different database technologies. Each have their pro's and con's but none have a consistent way to implement paging on the server side (ie the server only retrieves the rows needed for that page).

So we've had to implement our paging on the client side (by client side I mean the webserver as opposed to the database server). In a lot of respects this is dumb since we are forcing our web server to retrieve heaps of records into memory (which almost defeats the purpose of paging in the first place) and then determine which 20 records should be displayed. But we need the paging for of a UI reason (limited space).

Since it is likely that when the user see's a paged result set that they will navigate to at least one other page, we've implemented a client side cache. This saves us from making additional trips to the database to get the results of the other pages (since they were retrieved in the initial call).

The caveat of caching is its not the real data. If the data in the database changes, the user won't know about it for as long as they are using their cache. So we have a timeout on our cache. If its not hit within say 30 seconds, then another trip to the database is performed etc. The time to invalidate your cache depends heavily on the likelihood of data underneath changing and how important it is to display that data to the user.

Now to the second part of your question, how to implement the caching.

In ASP.Net 2 it is very easy, if you can use one of the datasource controls since they have caching built in. Which version of ASP.Net are you using?

Author Comment

ID: 16468233

I am using asp.net 1.1 for this application (hence the datagrid)

I do my paging using a stored procedure that only returns the relevant page of records at a time. I was wondering if there was any way to incorporate caching too or if that was overkill/pointless.


Accepted Solution

asdavey earned 2000 total points
ID: 16468242
I would argue that caching would probably not worth the effort but a lot does depend on how expensive your query is.

Instead of caching the results from the database server, you could consider looking at caching the output from the webserver. ASP.Net 1/1.1 does support caching a page (or parts thereof) so that instead of execute code on the server, the cached page (or part of page) is returned instead. I know that you can set the cache to invalidate after a period of time, and that the cache can be made dependant on what form/querystring variables are present.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question