最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Facebook Bigpipe Technique Algorithm - Stack Overflow

programmeradmin4浏览0评论

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 badges
Add a ment  | 

5 Answers 5

Reset to default 5

Well, 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:

  1. The browser will open an HTTP connection and will request a WEB page.
  2. 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)

  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

  4. While the connection is still open the server will open requests internally to all pagelets. here
  5. 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
  6. the function renderPagelet inside the Bigpipe.js file will use the JSON data to populate the HTML page.
  7. When all pagelets are served, the server will send closing </BODY></HTML> tags.
  8. 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

发布评论

评论列表(0)

  1. 暂无评论