continous feed clean up (phonegap specific?)

25 views
Skip to first unread message

Seung Chan Lim

unread,
Oct 21, 2014, 8:54:33 PM10/21/14
to mobile-c...@googlegroups.com
I have a question about continuous feeds (changes feed for example) in phonegap applications.

I'm using XMLHttpRequest object to keep alive a socket connection to "http://lite.couchbase." I get a callback everytime my readystate changes.

What I've noticed is that the new changes get appended to the http body. Now I could imagine this could grow quite large at times.

Is there any best practice for this? I suppose I could periodically disconnect re-establish a new connection (thus freeing up the memory) if I deem the buffer has grown too large, but I wanted to check if there are simpler/smarter ways of dealing with this.

slim

Jens Alfke

unread,
Oct 22, 2014, 12:08:43 PM10/22/14
to mobile-c...@googlegroups.com

> On Oct 21, 2014, at 5:54 PM, Seung Chan Lim <djs...@gmail.com> wrote:
>
> What I've noticed is that the new changes get appended to the http body. Now I could imagine this could grow quite large at times.

Interesting — that must just be a side effect of the way the XMLHTTPRequest object works.

> Is there any best practice for this?

I don't know. (Maybe JChris does?) You might ask around the CouchDB community, as this is something CouchApps would run into as well.

> I suppose I could periodically disconnect re-establish a new connection (thus freeing up the memory) if I deem the buffer has grown too large, but I wanted to check if there are simpler/smarter ways of dealing with this.

That sounds reasonable. You could also switch to the 'longpoll' feed, which will close the response after sending one update, after which you send another request.

—Jens
Reply all
Reply to author
Forward
0 new messages