Skip to content
Merged
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
12 changes: 12 additions & 0 deletions plugins/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ The third parameter to the ``CachePlugin`` constructor takes an array of options
| ``cache_key_generator`` | ``new SimpleGenerator()`` | A class implementing ``CacheKeyGenerator`` to generate a PSR-6 cache |
| | | key. |
+---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
| ``cache_listeners`` | ``[]`` | A array of classes implementing ``CacheListener`` to act on a |
| | | response with information on its cache status. |
+---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+


.. note::

Expand Down Expand Up @@ -100,6 +104,14 @@ You may define a method how the PSR-6 cache key should be generated. The default
is using the request method, URI and body of the request. The cache plugin does also include a ``HeaderCacheKeyGenerator``
which allow you to specify what HTTP header you want include in the cache key.

Controlling cache listeners
```````````````````````````

One or more classes implementing ``CacheListener`` can be added through ``cache_listeners``. These classes recieve a
notification on whether a request was a cache hit or miss, and can optionally mutate the response based on those signals.
As an example, adding the provided ``AddHeaderCacheListener`` will mutate the response, adding an ``X-Cache`` header with
a value ``HIT`` or ``MISS``, which can be useful in debugging.


Semantics of null values
````````````````````````
Expand Down