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