You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Marcello Nuccio <ma...@gmail.com> on 2011/04/08 12:25:32 UTC

Fetching many documents: multiple GETs or one POST?

To build the page of a Web app (built with couchapp), I need to fetch
by key many SELDOM CHANGING documents.
I can get them all with a single POST request with the keys in the body.
Or I can get them one by one with a GET request for each document.
The GET requests are cached by the browser, the POST is not.

So, which one is best?
Any suggestions?

Thanks,
  Marcello

Re: Fetching many documents: multiple GETs or one POST?

Posted by Marcello Nuccio <ma...@gmail.com>.
Yes, the documents change rarely and I want the same set of keys each time.

Very nice idea Sean. I can build a view to associate the set of
"static" documents I need to a given key, so I can get them all with a
single GET and it should be cacheable by the browser.

The nice thing about this trick is that I can create many sets of
documents identified by a key, so I can use the same view to
efficiently retrieve any set of rarely changing documents.

Anyone sees some problem with this technique?

thank,
  Marcello

2011/4/8 Sean Copenhaver <se...@gmail.com>:
> I believe it was said that the documents change rarely.
>
> Since it sounds like you want the same set of keys each time and the
> documents associated with those keys change rarely, it seems like you could
> add an attribute to the documents to use in a map function to associate them
> all together. Then let the browser cache the GET request to the view.
>
> On Fri, Apr 8, 2011 at 3:19 PM, Pierre-Alexandre Lacerte <
> pierrealexandre.lacerte@gmail.com> wrote:
>
>> Sean:
>> If the keys in your request change often, it doesn't make sense to build a
>> view map for a specific set of keys.
>> If the keys don't change, then it could be a good idea.
>>
>> Marcello, if your documents are changing often why do you want to cache the
>> request? You don't want to get the most recents one?
>>
>> I would prefer to do 1 single POST request instead of 50 GET requests...
>> Isn't it cleaner?
>>
>> Pierre
>>
>> On 2011-04-08, at 3:12 PM, Sean Copenhaver wrote:
>>
>> > Isn't a view request a GET? Could you potentially develop a view map
>> > function that gets these rarely updated documents you want and let the
>> > browser cache that request?  Anyone know if this would work this way?
>> >
>> > On Fri, Apr 8, 2011 at 6:25 AM, Marcello Nuccio
>> > <ma...@gmail.com>wrote:
>> >
>> >> To build the page of a Web app (built with couchapp), I need to fetch
>> >> by key many SELDOM CHANGING documents.
>> >> I can get them all with a single POST request with the keys in the body.
>> >> Or I can get them one by one with a GET request for each document.
>> >> The GET requests are cached by the browser, the POST is not.
>> >>
>> >> So, which one is best?
>> >> Any suggestions?
>> >>
>> >> Thanks,
>> >>  Marcello
>> >>
>> >
>> >
>> >
>> > --
>> > “The limits of language are the limits of one's world. “ -Ludwig von
>> > Wittgenstein
>>
>>
>
>
> --
> “The limits of language are the limits of one's world. “ -Ludwig von
> Wittgenstein
>

Re: Fetching many documents: multiple GETs or one POST?

Posted by Sean Copenhaver <se...@gmail.com>.
I believe it was said that the documents change rarely.

Since it sounds like you want the same set of keys each time and the
documents associated with those keys change rarely, it seems like you could
add an attribute to the documents to use in a map function to associate them
all together. Then let the browser cache the GET request to the view.

On Fri, Apr 8, 2011 at 3:19 PM, Pierre-Alexandre Lacerte <
pierrealexandre.lacerte@gmail.com> wrote:

> Sean:
> If the keys in your request change often, it doesn't make sense to build a
> view map for a specific set of keys.
> If the keys don't change, then it could be a good idea.
>
> Marcello, if your documents are changing often why do you want to cache the
> request? You don't want to get the most recents one?
>
> I would prefer to do 1 single POST request instead of 50 GET requests...
> Isn't it cleaner?
>
> Pierre
>
> On 2011-04-08, at 3:12 PM, Sean Copenhaver wrote:
>
> > Isn't a view request a GET? Could you potentially develop a view map
> > function that gets these rarely updated documents you want and let the
> > browser cache that request?  Anyone know if this would work this way?
> >
> > On Fri, Apr 8, 2011 at 6:25 AM, Marcello Nuccio
> > <ma...@gmail.com>wrote:
> >
> >> To build the page of a Web app (built with couchapp), I need to fetch
> >> by key many SELDOM CHANGING documents.
> >> I can get them all with a single POST request with the keys in the body.
> >> Or I can get them one by one with a GET request for each document.
> >> The GET requests are cached by the browser, the POST is not.
> >>
> >> So, which one is best?
> >> Any suggestions?
> >>
> >> Thanks,
> >>  Marcello
> >>
> >
> >
> >
> > --
> > “The limits of language are the limits of one's world. “ -Ludwig von
> > Wittgenstein
>
>


-- 
“The limits of language are the limits of one's world. “ -Ludwig von
Wittgenstein

Re: Fetching many documents: multiple GETs or one POST?

Posted by Pierre-Alexandre Lacerte <pi...@gmail.com>.
Sean:
If the keys in your request change often, it doesn't make sense to build a view map for a specific set of keys.
If the keys don't change, then it could be a good idea.

Marcello, if your documents are changing often why do you want to cache the request? You don't want to get the most recents one?

I would prefer to do 1 single POST request instead of 50 GET requests... Isn't it cleaner?

Pierre

On 2011-04-08, at 3:12 PM, Sean Copenhaver wrote:

> Isn't a view request a GET? Could you potentially develop a view map
> function that gets these rarely updated documents you want and let the
> browser cache that request?  Anyone know if this would work this way?
> 
> On Fri, Apr 8, 2011 at 6:25 AM, Marcello Nuccio
> <ma...@gmail.com>wrote:
> 
>> To build the page of a Web app (built with couchapp), I need to fetch
>> by key many SELDOM CHANGING documents.
>> I can get them all with a single POST request with the keys in the body.
>> Or I can get them one by one with a GET request for each document.
>> The GET requests are cached by the browser, the POST is not.
>> 
>> So, which one is best?
>> Any suggestions?
>> 
>> Thanks,
>>  Marcello
>> 
> 
> 
> 
> -- 
> “The limits of language are the limits of one's world. “ -Ludwig von
> Wittgenstein


Re: Fetching many documents: multiple GETs or one POST?

Posted by Sean Copenhaver <se...@gmail.com>.
Isn't a view request a GET? Could you potentially develop a view map
function that gets these rarely updated documents you want and let the
browser cache that request?  Anyone know if this would work this way?

On Fri, Apr 8, 2011 at 6:25 AM, Marcello Nuccio
<ma...@gmail.com>wrote:

> To build the page of a Web app (built with couchapp), I need to fetch
> by key many SELDOM CHANGING documents.
> I can get them all with a single POST request with the keys in the body.
> Or I can get them one by one with a GET request for each document.
> The GET requests are cached by the browser, the POST is not.
>
> So, which one is best?
> Any suggestions?
>
> Thanks,
>   Marcello
>



-- 
“The limits of language are the limits of one's world. “ -Ludwig von
Wittgenstein