From 2a22c8bcd1241a664da11692b824d54756897b7d Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Tue, 14 Feb 2017 13:24:24 +0700 Subject: [PATCH 1/4] Basic documentation of methods option --- plugins/cache.rst | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index febf6e5..8746f5d 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -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. -+---------------------------+---------------+------------------------------------------------------+ -| 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 | ++---------------------------+---------------------+------------------------------------------------------+ +| ``cache_lifetime`` | 30 days | The minimum time we should store a cache item | ++---------------------------+---------------------+------------------------------------------------------+ +| ``methods`` | ``['GET', 'HEAD']`` | Which request methods to cache | ++---------------------------+---------------------+------------------------------------------------------+ .. note:: @@ -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. + +.. 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 ---------------------- From 49f1741ff7805d4e01b8f43503a3e46e66d14191 Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Thu, 16 Feb 2017 19:58:58 +0700 Subject: [PATCH 2/4] Improve wording --- plugins/cache.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index 8746f5d..555f210 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -44,7 +44,7 @@ configure. Their default values and meaning is described by the table below. +===========================+=====================+======================================================+ | ``default_ttl`` | ``0`` | The default max age of a Response | +---------------------------+---------------------+------------------------------------------------------+ -| ``respect_cache_headers`` | ``true`` | Whatever or not we should care about cache headers | +| ``respect_cache_headers`` | ``true`` | Whether we should care about cache headers or not | +---------------------------+---------------------+------------------------------------------------------+ | ``cache_lifetime`` | 30 days | The minimum time we should store a cache item | +---------------------------+---------------------+------------------------------------------------------+ @@ -109,13 +109,15 @@ 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:: +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. +The ``methods`` setting overrides the defaults. If you want to keep caching ``GET`` and ``HEAD`` requests, you need +to include them. You can specify any request method that conforms to RFC-7230. Request methods are case sensitive, +this means ``post`` and ``POST`` are not the same. .. note:: From 6677e323dba079f152d14a2b9cdaba1b308a6093 Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Thu, 16 Feb 2017 20:10:21 +0700 Subject: [PATCH 3/4] The less words the better --- plugins/cache.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index 555f210..bd1d723 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -36,8 +36,7 @@ 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 four options you can -configure. Their default values and meaning is described by the table below. +The third parameter to the ``CachePlugin`` constructor takes an array of options. The available options are: +---------------------------+---------------------+------------------------------------------------------+ | Name | Default value | Description | From 5c4beeaa1b80505663fe0b687846e8802dad173e Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Mon, 20 Feb 2017 14:58:15 +0700 Subject: [PATCH 4/4] Only uppercase methods allowed --- plugins/cache.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index bd1d723..60049a1 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -115,8 +115,7 @@ based SOAP client you might want to additionally enable caching of ``POST`` requ ]; The ``methods`` setting overrides the defaults. If you want to keep caching ``GET`` and ``HEAD`` requests, you need -to include them. You can specify any request method that conforms to RFC-7230. Request methods are case sensitive, -this means ``post`` and ``POST`` are not the same. +to include them. You can specify any uppercase request method which conforms to :rfc:`7230`. .. note::