users@jersey.java.net

Re: [Jersey] Best practices for paging through a large sub resource

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Wed, 8 Oct 2008 15:04:15 -0700 (PDT)

For sending back a subset of the total dataset, you would want to use query paramters (as per your example):

/resources/portfolios/SandP500?pages=1,100

and use the @QueryParam("pages") to get the comma separated start/end offsets to return the subset of data.




----- Original Message ----
From: "Grazi, Victor" <victor.grazi_at_credit-suisse.com>
To: users_at_jersey.dev.java.net
Cc: "Li, Jun" <jun.li_at_credit-suisse.com>
Sent: Wednesday, October 8, 2008 9:42:15 AM
Subject: [Jersey] Best practices for paging through a large sub resource

Best practices for paging through a large sub resource
Does the scope of this group allow questions on best practices?
I am wondering from a ROA point of view, how to handle this case:
I want to get a sub-resource with many records, for example: /resources/portfolios/SandP500
In the client application, these will be displayed 20 companies at a time, a count that is configurable by the user.
I would like to divide the request into pages so as not to require returning all 500 pages at a time.
1. Is each page a different sub resource? That would be structured as:
/resources/portfolios/SandP500/page1
/resources/portfolios/SandP500/page2 etc?
That makes it difficult to configure per user, if they want to change that to 25 results at a time, etc, it would not scale.
2. Or do we make it one resource and pass in paging parameters
/resources/portfolios/SandP500?companies1-20
That makes it difficult to use a caching strategy with conditional gets. If I already cached companies 1 thru 20 and the resource did not change, but now I need 21 thru 30, it requires the client to manage the conditional get?
I guess the second approach makes the most sense - the client checks the cache before deciding to make a conditional request, but is that the best practice recommendation for this use case? It has a slight smell.
Is there a better suggestion?
Thanks, Victor
==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================