Skip to content

feat(http_cache): document xkey purger #1524

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

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ api_platform:
# To pass options to the client charged with the request.
request_options: []

# Use another service as the purger for example "api_platform.http_cache.purger.varnish.xkey"
purger: 'api_platform.http_cache.purger.varnish.ban'

# Automatically generate etags for API responses.
# Deprecated since 2.6 and will be removed in 3.0, use defaults.cache_headers.etag instead.
etag: true
Expand Down Expand Up @@ -372,6 +375,10 @@ api_platform:
# Default values of the "Vary" HTTP header.
vary: ['Accept']

invalidation:
xkey:
glue: ' '

normalization_context: ~
denormalization_context: ~
swagger_context: ~
Expand Down
21 changes: 21 additions & 0 deletions core/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ api_platform:
```

Support for reverse proxies other than Varnish can easily be added by implementing the `ApiPlatform\HttpCache\PurgerInterface`.
Two purgers are available, the http tags (`api_platform.http_cache.purger.varnish.ban`) or the surrogate key implementation
(`api_platform.http_cache.purger.varnish.xkey`). You can specify the implementation using the `purger` configuration node,
for example to use the xkey implementation:

```yaml
api_platform:
http_cache:
invalidation:
enabled: true
varnish_urls: ['%env(VARNISH_URL)%']
purger: 'api_platform.http_cache.purger.varnish.xkey'
public: true
defaults:
cache_headers:
max_age: 0
shared_max_age: 3600
vary: ['Content-Type', 'Authorization', 'Origin']
invalidation:
xkey:
glue: ', '
```

In addition to the cache invalidation mechanism, you may want to [use HTTP/2 Server Push to pre-emptively send relations
to the client](push-relations.md).
Expand Down