Skip to content

Commit ee5c213

Browse files
authored
Merge pull request #375 from FriendsOfSymfony/improve-tags-and-noop-doc
improve documentation for tags and noop client
2 parents 1887e19 + ec9284b commit ee5c213

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

Resources/doc/features/tagging.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ invalidations and flushes them. As with other invalidation operations, tag
4747
invalidation requests are flushed to the caching proxy
4848
:ref:`after the response has been sent <flushing>`.
4949

50-
Tagging from Code
51-
~~~~~~~~~~~~~~~~~
50+
Tagging and Invalidating from PHP Code
51+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5252

5353
To add tags to responses, inject the ``ResponseTagger`` (service
5454
``fos_http_cache.http.symfony_response_tagger``) and use ``addTags($tags)`` to
@@ -116,8 +116,8 @@ with the response tagger and can also be mixed with the other methods:
116116
Tag invalidation from twig would be a strange architecture and is therefore
117117
not supported.
118118

119-
Tagging with Configuration Rules
120-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119+
Tagging and Invalidating with Configuration Rules
120+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121121

122122
Alternatively, you can :doc:`configure rules </reference/configuration/tags>`
123123
for setting and invalidating tags:
@@ -137,8 +137,8 @@ Now if a :term:`safe` request matches the criteria under ``match``, the response
137137
will be tagged with ``news``. When an unsafe request matches, the tag ``news``
138138
will be invalidated.
139139

140-
Tagging with Controller Annotations
141-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140+
Tagging and Invalidating with Controller Annotations
141+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142142

143143
Add the ``@Tag`` annotations to your controllers to set and invalidate tags::
144144

Resources/doc/reference/configuration/proxy-client.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,26 @@ symfony
145145
146146
For ``servers`` and ``base_url``, see above.
147147

148+
.. _configuration_noop_proxy_client:
149+
148150
noop
149151
----
150152

151153
.. code-block:: yaml
152154
153-
# app/config/config.yml
155+
# app/config/config_test.yml
154156
fos_http_cache:
155157
proxy_client:
158+
default: noop
156159
noop: ~
157160
161+
This proxy client supports all invalidation methods, but implements doing
162+
nothing (hence the name "no operation" client). This can be useful for testing.
163+
158164
default
159165
-------
160166

161-
**type**: ``enum`` **options**: ``varnish``, ``nginx``, ``symfony``
167+
**type**: ``enum`` **options**: ``varnish``, ``nginx``, ``symfony``, ``noop``
162168

163169
.. code-block:: yaml
164170

Resources/doc/reference/configuration/tags.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ for an introduction.
77

88
.. include:: /includes/enabled.rst
99

10-
If you use a :doc:`proxy client that does not support banning </features/tagging>`,
11-
cache tagging is not possible. If you leave ``enabled`` on ``auto``, tagging will
12-
be deactivated.
10+
.. note::
11+
12+
If you use a :doc:`proxy client that does not support tag invalidation </features/tagging>`,
13+
cache tagging is not possible.
14+
15+
If you leave ``enabled`` on ``auto``, tagging will only be activated when
16+
using the varnish client.
17+
18+
When using the noop proxy client or a custom service, ``auto`` will also
19+
lead to tagging being disabled. If you want to use tagging in one of those
20+
cases, you need to explicitly enable tagging.
1321

1422
Enables tag annotations and rules. If you want to use tagging, it is recommended
1523
that you set this to ``true`` so you are notified of missing dependencies and
@@ -115,4 +123,4 @@ tag ``articles-123`` with the following configuration:
115123
The expression has access to all request attributes and the request itself
116124
under the name ``request``.
117125

118-
You can combine ``tags`` and ``tag_expression`` in one rule.
126+
You can combine ``tags`` and ``tag_expression`` in one rule.

Resources/doc/testing.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
Testing
22
=======
33

4-
Testing the Bundle
5-
------------------
4+
Testing your Application
5+
------------------------
6+
7+
If you do not want to test caching proxy interactions during testing, you can
8+
:ref:`use the Noop proxy client <configuration_noop_proxy_client>`. This
9+
client implements all invalidation features but does nothing at all.
10+
11+
If you want to write integration tests that validate your caching code and
12+
configuration against the actual caching proxy, have a look at the
13+
:ref:`FOSHttpCache library’s docs <foshttpcache:testing your application>`.
14+
15+
Testing the FOSHttpCacheBundle
16+
------------------------------
617

718
To run this bundle’s tests, clone the repository, install vendors, and invoke
819
PHPUnit:
@@ -13,9 +24,3 @@ PHPUnit:
1324
$ cd FOSHttpCacheBundle
1425
$ composer install
1526
$ vendor/bin/phpunit
16-
17-
.. tip::
18-
19-
See the :ref:`FOSHttpCache library’s docs <foshttpcache:testing your application>`
20-
on how to write integration tests that validate your caching code and
21-
configuration against a caching proxy.

0 commit comments

Comments
 (0)