Drupal8 render pipeline
-
Upload
mahesh-salaria -
Category
Technology
-
view
317 -
download
0
Transcript of Drupal8 render pipeline
Drupal 8 render pipeline
~ Mahesh Salaria (@salaria)Kelltontech
HttpKernal Component• The HttpKernel component provides a structured process for
converting a Request into a Response by making use of the EventDispatcher component. • Every HTTP web interaction begins with a request and ends with a
response. Your job as a developer is to create PHP code that reads the request information (e.g. the URL) and creates and returns a response (e.g. an HTML page or JSON string).
Routes• Routes whose controllers return a Response object bypass the
pipeline. They rely directly on the Symfony render pipeline.• Route whose controllers return the "main content" as a render
array automatically has the ability to be requested in multiple ways: it can be rendered in a certain format (HTML, JSON …) and/or in a certain decorated manner (e.g. with blocks around the main content).
Events• The glue between Symfony and Drupal.• Triggered by HttpKernel::handle()
Controllers• Business Logic to send response object or render array or an Object
associated with Event Subscriber.
Content Renderer• After the controller returned a render array, the VIEW will be
triggered by the HttpKernel, because the controller result is not a Response, but a render array.• MainContentViewSubscriber checks whether the negotiated request
format is supported.• All classes that implement MainContentRendererInterface• AjaxRenderer• DialogRenderer• HtmlRenderer• ModalRenderer
Placeholder strategies (HTML responses only) • SingleFlush (Traditional Way)• BigPipe (https://youtu.be/JwzX0Qv6u3A)
• During rendering, the personalized parts are turned into placeholders.• By default, Drupal 8 uses the Single Flush strategy (aka "traditional") for replacing the
placeholders. i.e. we don't send a response until we've replaced all placeholders.• The BigPipe module introduces a new strategy, that allows us to flush the initial page first,
and then stream the replacements for the placeholders.• This results in hugely improved front-end/perceived performance (watch the 40-second
screencast above).
BigPipe• BigPipe first breaks web pages into multiple chunks called pagelets
and process into several stages:• Request parsing: web server parses and sanity checks the HTTP request. • Data fetching: web server fetches data from storage tier.• Markup generation: web server generates HTML markup for the response. • Network transport: the response is transferred from web server to browser.• CSS downloading: browser downloads CSS required by the page.• DOM tree construction and CSS styling: browser constructs DOM tree of the document, and
then applies CSS rules on it. • JavaScript downloading: browser downloads JavaScript resources referenced by the page.• JavaScript execution: browser executes JavaScript code of the page.
Source: https://www.drupal.org/project/big_pipe
Refrences• https://www.drupal.org/developing/api/8/render/pipeline• https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!routin
g.api.php/group/routing• http://wimleers.com/talk/drupal-8-render-pipeline• https://www.drupal.org/project/big_pipe• https://www.facebook.com/notes/facebook-engineering/bigpipe-pip
elining-web-pages-for-high-performance/389414033919
Discussion!Thank you