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