diff --git a/web_link.rst b/web_link.rst index 8d626733344..35eab37db51 100644 --- a/web_link.rst +++ b/web_link.rst @@ -61,7 +61,7 @@ WebLink:
- + If you reload the page, the perceived performance will improve because the @@ -75,7 +75,7 @@ the priority of the resource to download using the ``importance`` attribute: - + .. tip:: @@ -88,8 +88,7 @@ How does it work? The WebLink component manages the ``Link`` HTTP headers added to the response. When using the ``preload()`` function in the previous example, the following -header was added to the response: ``Link ; rel="preload"`` - +header was added to the response: ``Link ; rel="preload"; as="style"`` According to `the Preload specification`_, when an HTTP/2 server detects that the original (HTTP 1.x) response contains this HTTP header, it will automatically trigger a push for the related file in the same HTTP/2 connection. @@ -105,7 +104,7 @@ issuing an early separate HTTP request, use the ``nopush`` option: - + Resource Hints @@ -139,7 +138,7 @@ any link implementing the `PSR-13`_ standard. For instance, any - + The previous snippet will result in this HTTP header being sent to the client: @@ -164,7 +163,7 @@ You can also add links to the HTTP response directly from controllers and servic // alternative if you don't want to use the addLink() shortcut $linkProvider = $request->attributes->get('_links', new GenericLinkProvider()); - $request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css'))); + $request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css', ['as' : 'style']))); return $this->render('...'); }