Skip to content

Basic documentation of cache plugin methods option #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 20, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions plugins/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ control headers from the server as specified in :rfc:`7234`. It needs a
Options
-------

The third parameter to the ``CachePlugin`` constructor takes an array of options. The plugin has 3 options you can
The third parameter to the ``CachePlugin`` constructor takes an array of options. The plugin has four options you can
configure. Their default values and meaning is described by the table below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just:

"The available options are:"


+---------------------------+---------------+------------------------------------------------------+
| Name | Default value | Description |
+===========================+===============+======================================================+
| ``default_ttl`` | ``0`` | The default max age of a Response |
+---------------------------+---------------+------------------------------------------------------+
| ``respect_cache_headers`` | ``true`` | Whatever or not we should care about cache headers |
+---------------------------+---------------+------------------------------------------------------+
| ``cache_lifetime`` | 30 days | The minimum time we should store a cache item |
+---------------------------+---------------+------------------------------------------------------+
+---------------------------+---------------------+------------------------------------------------------+
| Name | Default value | Description |
+===========================+=====================+======================================================+
| ``default_ttl`` | ``0`` | The default max age of a Response |
+---------------------------+---------------------+------------------------------------------------------+
| ``respect_cache_headers`` | ``true`` | Whatever or not we should care about cache headers |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Whatever/Whether/

(i see you only reformatted this, but just jumped into my eyes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe "Whether we should care about cache headers or not" would be proper english.

+---------------------------+---------------------+------------------------------------------------------+
| ``cache_lifetime`` | 30 days | The minimum time we should store a cache item |
+---------------------------+---------------------+------------------------------------------------------+
| ``methods`` | ``['GET', 'HEAD']`` | Which request methods to cache |
+---------------------------+---------------------+------------------------------------------------------+

.. note::

Expand Down Expand Up @@ -103,7 +105,22 @@ removed from the cache::
'cache_lifetime' => 86400*365, // one year
];

Caching of different request methods
````````````````````````````````````

Most of the time you should not change the ``methods`` option. However if you are working for example with HTTPlug
based SOAP client you might want to additionally enable caching of POST requests::

$options = [
'methods' => ['GET', 'HEAD', 'POST'],
];

You can cache any valid request method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe:

"methods" overwrites the default methods, if you want to keep caching GET and HEAD requests, you need to repeat them. You can specify any request method that conforms to RFC-7230. Note that request methods are case sensitive, so post and POST are not the same.


.. note::

If your system has both normal and SOAP clients you need to use two different ``PluginClient`` instances. SOAP
client should use ``PluginClient`` with POST caching enabled and normal client with POST caching disabled.

Cache Control Handling
----------------------
Expand Down