Skip to content

Commit 627cf43

Browse files
tuupolaNyholm
authored andcommitted
Basic documentation of cache plugin methods option (#174)
* Basic documentation of methods option * Improve wording * The less words the better * Only uppercase methods allowed
1 parent d8a5ecd commit 627cf43

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

plugins/cache.rst

+29-12
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ control headers from the server as specified in :rfc:`7234`. It needs a
3636
Options
3737
-------
3838

39-
The third parameter to the ``CachePlugin`` constructor takes an array of options. The plugin has 3 options you can
40-
configure. Their default values and meaning is described by the table below.
41-
42-
+---------------------------+---------------+------------------------------------------------------+
43-
| Name | Default value | Description |
44-
+===========================+===============+======================================================+
45-
| ``default_ttl`` | ``0`` | The default max age of a Response |
46-
+---------------------------+---------------+------------------------------------------------------+
47-
| ``respect_cache_headers`` | ``true`` | Whatever or not we should care about cache headers |
48-
+---------------------------+---------------+------------------------------------------------------+
49-
| ``cache_lifetime`` | 30 days | The minimum time we should store a cache item |
50-
+---------------------------+---------------+------------------------------------------------------+
39+
The third parameter to the ``CachePlugin`` constructor takes an array of options. The available options are:
40+
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+
+---------------------------+---------------------+------------------------------------------------------+
5152

5253
.. note::
5354

@@ -103,7 +104,23 @@ removed from the cache::
103104
'cache_lifetime' => 86400*365, // one year
104105
];
105106

107+
Caching of different request methods
108+
````````````````````````````````````
106109

110+
Most of the time you should not change the ``methods`` option. However if you are working for example with HTTPlug
111+
based SOAP client you might want to additionally enable caching of ``POST`` requests::
112+
113+
$options = [
114+
'methods' => ['GET', 'HEAD', 'POST'],
115+
];
116+
117+
The ``methods`` setting overrides the defaults. If you want to keep caching ``GET`` and ``HEAD`` requests, you need
118+
to include them. You can specify any uppercase request method which conforms to :rfc:`7230`.
119+
120+
.. note::
121+
122+
If your system has both normal and SOAP clients you need to use two different ``PluginClient`` instances. SOAP
123+
client should use ``PluginClient`` with POST caching enabled and normal client with POST caching disabled.
107124

108125
Cache Control Handling
109126
----------------------

0 commit comments

Comments
 (0)