You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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.
API Platform leverages this capability by pushing relations of a resource to clients.
8
10
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).
11
14
12
15
```php
13
16
<?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;
16
19
17
20
use ApiPlatform\Metadata\ApiProperty;
18
21
use ApiPlatform\Metadata\ApiResource;
@@ -27,13 +30,16 @@ class Book
27
30
}
28
31
```
29
32
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.
32
36
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.
34
39
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)
and [Akamai](https://blogs.akamai.com/2017/03/http2-server-push-the-what-how-and-why.html) honor this header.
37
43
38
44
Using this feature maximises HTTP cache hits for your API resources.
39
45
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