antoviaque/languagelearning — pull request #27 by antoviaque (2013-06-05 00:11:00+00:00)
Title: progressive-loading-api: Progressively return API result while built

First draft implementation, for experimentation.

Add `&progressive=1` at the end of an existing API query, and it will return the results progressively as they become available, instead of everything at once at the end.

There are three parts on which I'd specifically like to have comments before finalizing this:

* The `PROGRESSIVE_RESPONSE_BEGIN` tag string is currently very long, as in Firefox I only see the content being displayed progressively after a certain amount of data has been sent by the server - it is thus voluntarily long to allow to see the data displayed live in the browser while testing. We might be able to get rid of this tag completely if the readyState is immediately fired by browsers (ie if this is just behavior when *displaying* the data in the browser).

* Is the format of the separator good for you? We can change those, I don't particularly like the current format : )

* Currently the whole API response is resent every time - this allows to make things more generic, and even allow to modify information already sent in previous updates. Size is likely not an issue here, but if it makes things unpractical on the client side let me know.

Another aspect to be careful about before releasing this: the amount of caching that the reverse proxy (nginx currently) will be doing when forwarding the requests, and whether gzip compression has side effects here.