-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add docs for the WebLink component #10309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Do you know how to fix this (cryptic) RST error? https://travis-ci.org/symfony/symfony-docs/builds/426930279 |
About the RST issue, you must use this alternative format for the link of the line 64: `Bootstrap`_ |
looks like the failure was related to some whitespace issues (see 38fda88) |
Thanks a lot @xabbuh! |
weblink.rst
Outdated
brings great opportunities to boost webapp's performance. | ||
|
||
Thanks to WebLink, HTTP/2 (**h2**) servers are able to push resources to clients | ||
before they even know that they need them (think to CSS or JavaScript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think about
weblink.rst
Outdated
Thanks to WebLink, HTTP/2 (**h2**) servers are able to push resources to clients | ||
before they even know that they need them (think to CSS or JavaScript | ||
files, or relations of an API resource). WebLink also enables other very | ||
efficient optimisations that work with HTTP 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP 1.x or 1.1?
weblink.rst
Outdated
|
||
- telling the browser to fetch or to render another webpage in the | ||
background ; | ||
- init early DNS lookups, TCP handshakes or TLS negotiations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initializing
weblink.rst
Outdated
background ; | ||
- init early DNS lookups, TCP handshakes or TLS negotiations | ||
|
||
Let's discover how easy it is to use it and the real life benefits you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest removing this sentence
weblink.rst
Outdated
Let's discover how easy it is to use it and the real life benefits you | ||
can expect. | ||
|
||
To benefit from HTTP/2 Server Pushes, a HTTP/2 server and a HTTPS connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/a/an
weblink.rst
Outdated
_controller: 'Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction' | ||
template: 'homepage.html.twig' | ||
|
||
Refresh your browser, this nice homepage should appear: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/nice//
weblink.rst
Outdated
|
||
.. note:: | ||
|
||
Google Chrome provides a nice interface to debug HTTP/2 connections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/nice//
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afterwards s/a nice interface/an interface/
weblink.rst
Outdated
How does it works? | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
The WebLink component tracks Link HTTP headers to add to the response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing backticks around Link
weblink.rst
Outdated
.. image:: /_images/components/weblink/response-headers.png | ||
|
||
According to `the Preload specification`_, | ||
when a HTTP/2 server detects that the original (HTTP 1) response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an HTTP + HTTP 1.x
weblink.rst
Outdated
browsers. | ||
|
||
In addition to HTTP/2 Push and preloading, the WebLink component also | ||
provide some helpers to send `Resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provides
Hey @dunglas, you mention some twig helpers in your blog post, but they are not included in the component itself, is a bridge or anything else available? Or am I missing sth? |
Yes, they belong in the TwigBridge. |
Than you very much @nicolas-grekas, changes applied. |
…k() (dunglas) This PR was squashed before being merged into the 4.2-dev branch (closes #28875). Discussion ---------- [FWBundle] Add a new method AbstractController::addLink() | Q | A | ------------- | --- | Branch? | master | Bug fix? |no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | todo This provides a convenient method to add `Link` headers to the current `Response` directly from the `Request` object. It improves the developer experience and the discoverability of [the WebLink component](symfony/symfony-docs#10309). Usage: ```php namespace App\Controller; use Fig\Link\Link; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class MyAction extends AbstractController { public function __invoke(Request $request): Response { $this->addLink($request, new Link('mercure', 'https://demo.mercure.rocks')); return $this->json(['foo' => 'bar']); } } ``` Commits ------- 4d20c39f70 [FWBundle] Add a new method AbstractController::addLink()
…k() (dunglas) This PR was squashed before being merged into the 4.2-dev branch (closes #28875). Discussion ---------- [FWBundle] Add a new method AbstractController::addLink() | Q | A | ------------- | --- | Branch? | master | Bug fix? |no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | todo This provides a convenient method to add `Link` headers to the current `Response` directly from the `Request` object. It improves the developer experience and the discoverability of [the WebLink component](symfony/symfony-docs#10309). Usage: ```php namespace App\Controller; use Fig\Link\Link; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class MyAction extends AbstractController { public function __invoke(Request $request): Response { $this->addLink($request, new Link('mercure', 'https://demo.mercure.rocks')); return $this->json(['foo' => 'bar']); } } ``` Commits ------- 4d20c39 [FWBundle] Add a new method AbstractController::addLink()
This PR was merged into the 3.4 branch. Discussion ---------- Add docs for the WebLink component The WebLink component is available since Symfony 3.3, but I never took the time to add the docs (however, a blog post explaining how to use it was available). This documentation is based on https://dunglas.fr/2017/10/symfony-4-http2-push-and-preloading/. If necessary, I can grant any copyright regarding this post to the Symfony project. symfony/symfony#21478 symfony/symfony#22273 Closes #7515. Commits ------- 91ee3bc Fix RST ea7b3da @nicolas-grekas' review 38fda88 fix build e12e776 RST 088690f Fix link e3d4036 RST 178821e refactor 9f4ae9b fix typo 6beb4eb Add docs for the WebLink component
Thanks Kévin for contributing this doc (and the component too!). I made some changes while merging, specially on the main |
The WebLink component is available since Symfony 3.3, but I never took the time to add the docs (however, a blog post explaining how to use it was available).
This documentation is based on https://dunglas.fr/2017/10/symfony-4-http2-push-and-preloading/.
If necessary, I can grant any copyright regarding this post to the Symfony project.
symfony/symfony#21478
symfony/symfony#22273
Closes #7515.