Recently, I read an article by Facebook about their new page pipelining system. Currently, there are several Github projects with similar implementations, but they are all written in Php.
What is BigPipe?
BigPipe is a system that Facebook has come up with that makes it seem that pages load faster. A single page is divided into small pagelets, so it looks like this, where each box is a pagelet:
So the logic of loading a whole web page turns into:
Their data shows around a 2x page load time improvement.
The Problem
The main problem with implementing this in Pyramid is that I have not found a way to keep a persistent HTTP connection with the client to be able to flush these "pagelets" down the pipe. I've experimented with response.app_iter
, but the generator yields are not be flushed, rather the whole response is being generated first, then flushed all at once down the pipe. Is there a way to flush multiple "responses" down a persistent connection with Pyramid?
From here: https://webob.readthedocs.org/en/latest/differences.html?highlight=stream
This can make CherryPy stream the response body out directory. There is direct no equivalent; you can use a dynamically generated iterator to do something similar.
Pyramid uses the webob library to model requests and responses, from the documentation of which the above quotation is taken. Accordingly, I would say there is no way to do this with "Standard" Pyramid/Pylons.
Instead, you are going to have to use a different library to process responses (and maybe requests). This may give you some ideas on how to do that: http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/designdefense.html
Alternatively, you might try subclassing the response object to add that functionality, possibly by delegating to code from another library which does support that.
You should probably select a library which does support this, and ask on the Pyramid mailing list how best to hook that in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With