@@ -33,22 +33,33 @@ control headers from the server as specified in :rfc:`7234`. It needs a
33
33
[$cachePlugin]
34
34
);
35
35
36
+ .. note ::
37
+
38
+ Since v1.3.0 does the ``CachePlugin `` have 2 factory methods to easily setup the plugin by caching type.
39
+
40
+ .. code-block :: php
41
+ $cachePlugin = CachePlugin::clientCache($pool, $streamFactory, $options); // Which allows caching responses with the ``private`` or ``no-store`` cache directive
42
+ $cachePlugin = CachePlugin::serverCache($pool, $streamFactory, $options); // Returns a cache plugin with the current default behavior
43
+
36
44
Options
37
45
-------
38
46
39
47
The third parameter to the ``CachePlugin `` constructor takes an array of options. The available options are:
40
48
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
- +---------------------------+---------------------+------------------------------------------------------+
49
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
50
+ | Name | Default value | Description |
51
+ +=======================================+====================================================+=======================================================================+
52
+ | ``default_ttl `` | ``0 `` | The default max age of a Response |
53
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
54
+ | ``respect_cache_headers `` | ``true `` | Whether we should care about cache headers or not |
55
+ | | | * This option is deprecated. Use `respect_response_cache_directives ` |
56
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
57
+ | ``cache_lifetime `` | 30 days | The minimum time we should store a cache item |
58
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
59
+ | ``methods `` | ``['GET', 'HEAD'] `` | Which request methods to cache |
60
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
61
+ | ``respect_response_cache_directives `` | ``['no-cache', 'private', 'max-age', 'no-store'] `` | A list of cache directives to respect when caching responses |
62
+ +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+
52
63
53
64
.. note ::
54
65
@@ -68,7 +79,7 @@ for the default time to live. The options below will cache all responses for one
68
79
69
80
$options = [
70
81
'default_ttl' => 3600, // cache for one hour
71
- 'respect_cache_headers ' => false ,
82
+ 'respect_response_cache_directives ' => [] ,
72
83
];
73
84
74
85
Semantics of null values
@@ -81,7 +92,7 @@ Store a response as long the cache implementation allows::
81
92
82
93
$options = [
83
94
'default_ttl' => null,
84
- 'respect_cache_headers ' => false ,
95
+ 'respect_response_cache_directives ' => [] ,
85
96
'cache_lifetime' => null,
86
97
];
87
98
@@ -90,7 +101,7 @@ Ask the server if the response is valid at most ever hour. Store the cache item
90
101
91
102
$options = [
92
103
'default_ttl' => 3600,
93
- 'respect_cache_headers ' => false ,
104
+ 'respect_response_cache_directives ' => [] ,
94
105
'cache_lifetime' => null,
95
106
];
96
107
@@ -100,7 +111,7 @@ removed from the cache::
100
111
101
112
$options = [
102
113
'default_ttl' => 3600,
103
- 'respect_cache_headers ' => false ,
114
+ 'respect_response_cache_directives ' => [] ,
104
115
'cache_lifetime' => 86400*365, // one year
105
116
];
106
117
@@ -125,7 +136,9 @@ to include them. You can specify any uppercase request method which conforms to
125
136
Cache Control Handling
126
137
----------------------
127
138
128
- This plugin does not cache responses with ``no-store `` or ``private `` instructions.
139
+ By default this plugin does not cache responses with ``no-store `` or ``private `` instructions. If you need to cache
140
+ responses with these cache directives you should setup the plugin with ``CachePlugin::clientCache($pool, $streamFactory, $options); ``
141
+ or change the ``respect_response_cache_directives `` to your needs.
129
142
130
143
It does store responses with cookies or a ``Set-Cookie `` header. Be careful with
131
144
the order of your plugins.
0 commit comments