@@ -33,22 +33,40 @@ control headers from the server as specified in :rfc:`7234`. It needs a
3333 [$cachePlugin]
3434 );
3535
36+
37+ The ``CachePlugin `` has also 2 factory methods to easily setup the plugin by caching type. See the example below.
38+
39+ .. code-block :: php
40+
41+ // This will allows caching responses with the 'private' and/or 'no-store' cache directives
42+ $cachePlugin = CachePlugin::clientCache($pool, $streamFactory, $options);
43+
44+ // Returns a cache plugin with the current default behavior
45+ $cachePlugin = CachePlugin::serverCache($pool, $streamFactory, $options);
46+
47+ .. note ::
48+
49+ The two factory methods have been added in version 1.3.0.
50+
3651Options
3752-------
3853
3954The third parameter to the ``CachePlugin `` constructor takes an array of options. The available options are:
4055
41- +---------------------------+---------------------+------------------------------------------------------+
42- | Name | Default value | Description |
43- +===========================+=====================+======================================================+
44- | ``default_ttl `` | ``0 `` | The default max age of a Response |
45- +---------------------------+---------------------+------------------------------------------------------+
46- | ``respect_cache_headers `` | ``true `` | Whether we should care about cache headers or not |
47- +---------------------------+---------------------+------------------------------------------------------+
48- | ``cache_lifetime `` | 30 days | The minimum time we should store a cache item |
49- +---------------------------+---------------------+------------------------------------------------------+
50- | ``methods `` | ``['GET', 'HEAD'] `` | Which request methods to cache |
51- +---------------------------+---------------------+------------------------------------------------------+
56+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
57+ | Name | Default value | Description |
58+ +=======================================+====================================================+=======================================================================+
59+ | ``default_ttl `` | ``0 `` | The default max age of a Response |
60+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
61+ | ``respect_cache_headers `` | ``true `` | Whether we should care about cache headers or not |
62+ | | | * This option is deprecated. Use `respect_response_cache_directives ` |
63+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
64+ | ``cache_lifetime `` | 30 days | The minimum time we should store a cache item |
65+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
66+ | ``methods `` | ``['GET', 'HEAD'] `` | Which request methods to cache |
67+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
68+ | ``respect_response_cache_directives `` | ``['no-cache', 'private', 'max-age', 'no-store'] `` | A list of cache directives to respect when caching responses |
69+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
5270
5371.. note ::
5472
@@ -68,7 +86,7 @@ for the default time to live. The options below will cache all responses for one
6886
6987 $options = [
7088 'default_ttl' => 3600, // cache for one hour
71- 'respect_cache_headers ' => false ,
89+ 'respect_response_cache_directives ' => [] ,
7290 ];
7391
7492Semantics of null values
@@ -81,7 +99,7 @@ Store a response as long the cache implementation allows::
8199
82100 $options = [
83101 'default_ttl' => null,
84- 'respect_cache_headers ' => false ,
102+ 'respect_response_cache_directives ' => [] ,
85103 'cache_lifetime' => null,
86104 ];
87105
@@ -90,7 +108,7 @@ Ask the server if the response is valid at most ever hour. Store the cache item
90108
91109 $options = [
92110 'default_ttl' => 3600,
93- 'respect_cache_headers ' => false ,
111+ 'respect_response_cache_directives ' => [] ,
94112 'cache_lifetime' => null,
95113 ];
96114
@@ -100,7 +118,7 @@ removed from the cache::
100118
101119 $options = [
102120 'default_ttl' => 3600,
103- 'respect_cache_headers ' => false ,
121+ 'respect_response_cache_directives ' => [] ,
104122 'cache_lifetime' => 86400*365, // one year
105123 ];
106124
@@ -125,7 +143,9 @@ to include them. You can specify any uppercase request method which conforms to
125143Cache Control Handling
126144----------------------
127145
128- This plugin does not cache responses with ``no-store `` or ``private `` instructions.
146+ By default this plugin does not cache responses with ``no-store ``, ``no-cache `` or ``private `` instructions. Use
147+ ``CachePlugin::clientCache($pool, $streamFactory, $options); `` to cache ``no-store `` or ``private `` responses or change
148+ the ``respect_response_cache_directives `` option to your needs.
129149
130150It does store responses with cookies or a ``Set-Cookie `` header. Be careful with
131151the order of your plugins.
0 commit comments