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
Copy file name to clipboardExpand all lines: core/performance.md
+15-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
3
3
## Enabling the Built-in HTTP Cache Invalidation System
4
4
5
-
Exposing a hypermedia API has [many advantages](http://blog.theamazingrando.com/in-band-vs-out-of-band.html). One of them
5
+
Exposing a hypermedia API has [many advantages](http://blog.theamazingrando.com/in-band-vs-out-of-band.html). One
6
6
is the ability to know exactly which resources are included in HTTP responses created by the API. We used this specificity
7
7
to make API Platform apps blazing fast.
8
8
9
9
When the cache mechanism [is enabled](configuration.md), API Platform collects identifiers of every resource included in
10
-
a given HTTP response (including lists, embedded documents and subresources) and returns them in a special HTTP header
10
+
a given HTTP response (including lists, embedded documents, and subresources) and returns them in a special HTTP header
11
11
called [Cache-Tags](https://support.cloudflare.com/hc/en-us/articles/206596608-How-to-Purge-Cache-Using-Cache-Tags-Enterprise-only-).
12
12
13
13
A caching [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy) supporting cache tags (e.g. Varnish, Cloudflare,
@@ -16,17 +16,17 @@ This means that after the first request, all subsequent requests will not hit th
16
16
from the cache.
17
17
18
18
When a resource is modified, API Platform takes care of purging all responses containing it in the proxy’s
19
-
cache. This ensures that the content served will always be fresh, because the cache is purged in realtime. Support for
19
+
cache. This ensures that the content served will always be fresh because the cache is purged in real-time. Support for
20
20
most specific cases such as the invalidation of collections when a document is added or removed or for relationships and
21
21
inverse relations is built-in.
22
22
23
23
### Integrations
24
24
25
25
#### Built-in Caddy HTTP cache
26
26
27
-
The API Platform distribution relies on the [Caddy web server](https://caddyserver.com) which provide an official HTTP cache module called [cache-handler](https://github.com/caddyserver/cache-handler), that is based on [Souin](https://github.com/darkweak/souin).
27
+
The API Platform distribution relies on the [Caddy web server](https://caddyserver.com) which provides an official HTTP cache module called [cache-handler](https://github.com/caddyserver/cache-handler), that is based on [Souin](https://github.com/darkweak/souin).
28
28
29
-
The integration using the cache-handler is quite simple. You juste have to update the `api/Dockerfile` to build your caddy instance with the HTTP cache
29
+
The integration using the cachehandler is quite simple. You just have to update the `api/Dockerfile` to build your caddy instance with the HTTP cache
30
30
31
31
```diff
32
32
# Versions
@@ -61,7 +61,7 @@ Update your Caddyfile with the following configuration:
61
61
}
62
62
}
63
63
```
64
-
This will tell to caddy to use the HTTP cache and activate the tagbased invalidation API. You can refer to the [cache-handler documentation](https://github.com/caddyserver/cache-handler) or the [souin website documentation](https://docs.souin.io) to learn how to configure the HTTP cache server.
64
+
This will tell to caddy to use the HTTP cache and activate the tag-based invalidation API. You can refer to the [cache-handler documentation](https://github.com/caddyserver/cache-handler) or the [souin website documentation](https://docs.souin.io) to learn how to configure the HTTP cache server.
65
65
66
66
Setup the HTTP cache invalidation in your API Platform project
67
67
```yaml
@@ -96,6 +96,7 @@ api_platform:
96
96
```
97
97
98
98
## Configuration
99
+
99
100
Support for reverse proxies other than Varnish or Caddy with the HTTP cache module can be added by implementing the `ApiPlatform\HttpCache\PurgerInterface`.
100
101
Three purgers are available, the built-in caddy http cache purger (`api_platform.http_cache.purger.souin`), the http tags (`api_platform.http_cache.purger.varnish.ban`), the surrogate key implementation
101
102
(`api_platform.http_cache.purger.varnish.xkey`). You can specify the implementation using the `purger` configuration node,
@@ -411,7 +412,7 @@ More details are available on the [pagination documentation](pagination.md#parti
411
412
412
413
Blackfire.io allows you to monitor the performance of your applications. For more information, visit the [Blackfire.io website](https://blackfire.io/).
413
414
414
-
To configure Blackfire.io follow these simple steps:
415
+
To configure Blackfire.io follow these steps:
415
416
416
417
1. Add the following to your `compose.override.yaml` file:
First, [create a PHP debug remote server configuration](https://www.jetbrains.com/help/phpstorm/creating-a-php-debug-server-configuration.html):
19
+
20
+
1. In the `Settings/Preferences` dialog, go to `PHP | Servers`
21
+
2. Create a new server:
22
+
* Name: `api` (or whatever you want to use for the variable `PHP_IDE_CONFIG`)
23
+
* Host: `localhost` (or the one defined using the `SERVER_NAME` environment variable)
24
+
* Port: `443`
25
+
* Debugger: `Xdebug`
26
+
* Check `Use path mappings`
27
+
* Map the local `api/` directory to the `/app` absolute path on the server
28
+
29
+
You can now use the debugger!
30
+
31
+
1. In PhpStorm, open the `Run` menu and click on `Start Listening for PHP Debug Connections`
32
+
2. Add the `XDEBUG_SESSION=PHPSTORM` query parameter to the URL of the page you want to debug or use [other available triggers](https://xdebug.org/docs/step_debug#activate_debugger).
33
+
Alternatively, you can use [the Xdebug extension](https://xdebug.org/docs/step_debug#browser-extensions) for your preferred web browser.
34
+
35
+
3. On the command-line, we might need to tell PhpStorm which [path mapping configuration](https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging-cli.html#configure-path-mappings) should be used, set the value of the PHP_IDE_CONFIG environment variable to `serverName=api`, where `api` is the name of the debug server configured higher.
0 commit comments