tags:

views:

19

answers:

1

My google search application making a request each time while i am using paginator. Suppose i have a 100 records. Each page have to show 10 records so ten pages. When i click 2nd page it again sending a request. Ideally it should not send the request.

+1  A: 

When i click 2nd page it again sending a request. Ideally it should not send the request.

What do you mean by request? Is it a request to Google?

Your application apparently does not cache the results. If your request to Google returns 100 pages then you should cache those hundred. When you request the second page the view should retrieve this cache and return the second page to you.

If you mean request to your app, then @Daniel's comment has it right. You can get around this by sending all the results to the browser and then do the pagination using JavaScript to avoid this.

A more detailed answer is difficult without seeing some code.

Manoj Govindan
@Manoj: Yup it is a google request.
alis
@Manoj: But when you go to the next page it should not go to the google again. Because we have already 100 results.
alis
@alis: For this the request should _cache_ those 100 results and return the first 10. The next time the view is called it should look up the page number, retrieve the cached results and finally serve the results corresponding to that page number. You will need to add a way to figure out if the request is for a cached Google query or a new one.
Manoj Govindan
alis