I keep studying this flow of the Facebook's bigpipe technique but I have this question.
How this thing is implemented? does the pagelet is received through an ajax request? I keep on searching for the source code of this bigpipe but it points me to a 404 page of github.
Can someone explain this bigpipe in a low level(programming algorithm) way. I'm really interested with this technique.
Thanks in advance
I keep studying this flow of the Facebook's bigpipe technique but I have this question.
How this thing is implemented? does the pagelet is received through an ajax request? I keep on searching for the source code of this bigpipe but it points me to a 404 page of github.
Can someone explain this bigpipe in a low level(programming algorithm) way. I'm really interested with this technique.
Thanks in advance
Share Improve this question edited May 25, 2013 at 1:31 Netorica asked Feb 2, 2012 at 3:11 NetoricaNetorica 19.3k19 gold badges77 silver badges109 bronze badges5 Answers
Reset to default 5Well, no, the main content and pagelets are received with the same connection. The pagelets are simply streamed as they are generated to the browser, and placed in the document with Javascript.
You can find an open (and simple) BigPipe implementation in PHP here.
I developed a simple page framework recently. The core idea is to separate a page into several features, each of which will be handled in parallel. The output of each feature is an HTML segment, which the framework then assembles by layout configuration. The first version is not perfect. If you get interested, check here https://github./chennanfei/Moonlight
Before explaining in detail how Bigpipe works, I will mention I developed a Django extension that implements Bigpipe. Bigpipe-Response.
I will use Bigpipe-Response code to illustrate how Bigpipe works.
Bigpipe is using the initial connection made by the browser, in the following steps:
- The browser will open an HTTP connection and will request a WEB page.
The server will send back the HTML.
a. Without closing</BODY></HTML>
tags. This way to browser assumes that the connection is still open.
b. The HTML will contain empty<DIV id="pagelet-1"></DIV>
elements where bigpipe fill a pagelet content.
c. Small javascript at the top of the page is included (see step 3)At the top of the page, there is a small javascript function that accepts JSON and populates the page with that JSON content. bigpipe.js
- While the connection is still open the server will open requests internally to all pagelets. here
- When a response from a pagelet is available the server will wrap the response data in a JSON (this includes JS, CSS, i18n, links, etc...). and will send it as a parameter for a javascript function call. see here
- the function
renderPagelet
inside theBigpipe.js
file will use the JSON data to populate the HTML page. - When all pagelets are served, the server will send closing
</BODY></HTML>
tags. - The HTTP connection will be closed here
Hope this helps. for more info, you can refer to the documentation Here.
I am a asp mvc developer. I found a fairly good example of how to implement BigPipe using asp mvc pipeline. You can find the source code and explanation here:
https://github./JMPerez/BigPipe
He also tried to check if JavaScript exists or not and if it doesn't exists the content gets flushed into view on server. I like his article because he also discuss the downsides of his implementation.
I am trying to apply his example to ZenZoy Wish me luck.
you could check out the Java implementation of bigpipe here