Skip to content

Commit 90de5ab

Browse files
docs(push-relations): compatibility with laravel and improve (#2083)
1 parent d5f9c64 commit 90de5ab

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

core/push-relations.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# Pushing Related Resources Using HTTP/2
22

3-
> HTTP/2 allows a server to pre-emptively send (or "push") responses (along with corresponding "promised" requests) to a client in association with a previous client-initiated request. This can be useful when the server knows the client will need to have those responses available in order to fully process the response to the original request.
3+
> HTTP/2 allows a server to pre-emptively send (or "push") responses (along with corresponding "promised" requests) to
4+
> a client in association with a previous client-initiated request. This can be useful when the server knows the client
5+
> will need to have those responses available in order to fully process the response to the original request.
46
>
57
> [RFC 7540](https://tools.ietf.org/html/rfc7540#section-8.2)
68
79
API Platform leverages this capability by pushing relations of a resource to clients.
810

9-
**Note:** We strongly recommend using [Vulcain](https://vulcain.rocks) instead of this feature.
10-
Vulcain is faster, cleaner, more flexible, and is supported out of the box in [the API Platform distribution](../symfony/index.md).
11+
> [!NOTE]
12+
> We strongly recommend using [Vulcain](https://vulcain.rocks) instead of this feature.
13+
> Vulcain is faster, cleaner, more flexible, and is supported out of the box in [the API Platform distribution](../symfony/index.md).
1114
1215
```php
1316
<?php
14-
// api/src/Entity/Book.php
15-
namespace App\Entity;
17+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
18+
namespace App\ApiResource;
1619

1720
use ApiPlatform\Metadata\ApiProperty;
1821
use ApiPlatform\Metadata\ApiResource;
@@ -27,13 +30,16 @@ class Book
2730
}
2831
```
2932

30-
By setting the `push` attribute to `true` on a property holding a relation, API Platform will automatically add a valid `Link` HTTP header with the `preload` relation.
31-
According to the [Preload W3C Candidate Recommendation](https://www.w3.org/TR/preload/#server-push-http-2), web servers and proxy servers can read this header, fetch the related resource and send it to the client using Server Push.
33+
By setting the `push` attribute to `true` on a property holding a relation, API Platform will automatically add a valid
34+
`Link` HTTP header with the `preload` relation. According to the [Preload W3C Candidate Recommendation](https://www.w3.org/TR/preload/#server-push-http-2),
35+
web servers and proxy servers can read this header, fetch the related resource and send it to the client using Server Push.
3236

33-
With the Caddy web server (the server shipped as part of the [distribution](../symfony/index.md)), you must add [the `push` directive](https://caddyserver.com/docs/caddyfile/directives/push) to your `Caddyfile` to be able to use this feature.
37+
With the Caddy web server (the server shipped as part of the [distribution](../symfony/index.md)), you must add
38+
[the `push` directive](https://caddyserver.com/docs/caddyfile/directives/push) to your `Caddyfile` to be able to use this feature.
3439

35-
[NGINX](https://www.nginx.com/blog/nginx-1-13-9-http2-server-push/), [Apache](https://httpd.apache.org/docs/current/howto/http2.html#push), [Cloudflare](https://www.cloudflare.com/website-optimization/http2/serverpush/), [Fastly](https://docs.fastly.com/guides/performance-tuning/http2-server-push) and [Akamai](https://blogs.akamai.com/2017/03/http2-server-push-the-what-how-and-why.html)
36-
honor this header.
40+
[NGINX](https://www.nginx.com/blog/nginx-1-13-9-http2-server-push/), [Apache](https://httpd.apache.org/docs/current/howto/http2.html#push),
41+
[Cloudflare](https://www.cloudflare.com/website-optimization/http2/serverpush/), [Fastly](https://docs.fastly.com/guides/performance-tuning/http2-server-push)
42+
and [Akamai](https://blogs.akamai.com/2017/03/http2-server-push-the-what-how-and-why.html) honor this header.
3743

3844
Using this feature maximises HTTP cache hits for your API resources.
3945
For best performance, this feature should be used in conjunction with [the built-in HTTP cache invalidation system (based on Varnish)](performance.md#enabling-the-built-in-http-cache-invalidation-system).

0 commit comments

Comments
 (0)