1
- Extra Invalidation Handlers
2
- ===========================
1
+ Response Tagging
2
+ ================
3
3
4
- This library provides decorators that build on top of the ``CacheInvalidator ``
5
- to simplify common operations .
4
+ This library provides a service to handle tagging of responses ``ResponseTagger ``
5
+ to simplify use of tags .
6
6
7
7
.. _tags :
8
8
9
- Tag Handler
10
- -----------
9
+ Response Tagger
10
+ ---------------
11
11
12
- The tag handler helps you to mark responses with tags that you can later use to
13
- invalidate all cache entries with that tag. Tag invalidation works only with a
14
- `` CacheInvalidator `` that supports ``CacheInvalidator::INVALIDATE ``.
12
+ The ResponseTagger helps you to mark responses with tags that you can later use to
13
+ invalidate all cache entries with that tag. Response Tagging and tag invalidation
14
+ require a proxy client that implements ``TagsInterface ``.
15
15
16
16
Setup
17
17
~~~~~
@@ -20,29 +20,28 @@ Setup
20
20
21
21
Make sure to :doc: `configure your proxy <proxy-configuration >` for tagging first.
22
22
23
- The tag handler is a decorator around the ``CacheInvalidator ``. After
24
- :doc: `creating the invalidator <cache-invalidator >` with a proxy client
25
- that implements the ``BanInterface ``, instantiate the ``TagHandler ``::
23
+ The response tagger is a decorator around a proxy client that implements
24
+ the ``TagsInterface ``, handling tags for the current response::
26
25
27
- use FOS\HttpCache\Handler\TagHandler ;
26
+ use FOS\HttpCache\ResponseTagger ;
28
27
29
- // $cacheInvalidator already created as instance of FOS\HttpCache\CacheInvalidator
30
- $tagHandler = new TagHandler($cacheInvalidator );
28
+ // $proxyClient already created, implementing FOS\HttpCache\ProxyClient\Invalidation\TagsInterface
29
+ $responseTagger = new ResponseTagger($proxyClient );
31
30
32
31
Usage
33
32
~~~~~
34
33
35
34
With tags you can group related representations so it becomes easier to
36
35
invalidate them. You will have to make sure your web application adds the
37
- correct tags on all responses. You can add tags to the handler using::
36
+ correct tags on all responses. You can add tags to the response using::
38
37
39
- $tagHandler ->addTags(['tag-two', 'group-a']);
38
+ $responseTagger ->addTags(['tag-two', 'group-a']);
40
39
41
40
Before any content is sent out, you need to send the tag header _::
42
41
43
42
header(sprintf('%s: %s'),
44
- $tagHandler ->getTagsHeaderName(),
45
- $tagHandler ->getTagsHeaderValue()
43
+ $responseTagger ->getTagsHeaderName(),
44
+ $responseTagger ->getTagsHeaderValue()
46
45
);
47
46
48
47
.. tip ::
@@ -75,21 +74,21 @@ Only ``/one`` will stay in the cache.
75
74
76
75
.. note ::
77
76
78
- Don't forget to call :ref: `flush <flush >` on the ``CacheInvalidator `` to commit the invalidations
79
- to the caching proxy.
80
-
81
- .. _custom_tags_header :
77
+ For further reading on tag invalidation see :doc: `cache-invalidator page <cache-invalidator >`.
78
+ For changing the cache header, :doc: `configure your proxy <proxy-clients >`
82
79
83
80
Custom Tags Header
84
81
~~~~~~~~~~~~~~~~~~
85
82
83
+ // TOOO: Move or change to reflect that this depends on Proxy Client.
84
+
86
85
Tagging uses a custom HTTP header to identify tags. You can change the default
87
86
header ``X-Cache-Tags `` in the constructor::
88
87
89
- use FOS\HttpCache\Handler\TagHandler ;
88
+ use FOS\HttpCache\ResponseTagger ;
90
89
91
90
// $cacheInvalidator already created as instance of FOS\HttpCache\CacheInvalidator
92
- $tagHandler = new TagHandler ($cacheInvalidator, 'My-Cache-Header');
91
+ $responseTagger = new ResponseTagger ($cacheInvalidator, 'My-Cache-Header');
93
92
94
93
Make sure to reflect this change in your
95
94
:doc: `caching proxy configuration <proxy-configuration >`.
0 commit comments