1- Extra Invalidation Handlers
2- ===========================
1+ Response Tagging
2+ ================
33
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 .
66
77.. _tags :
88
9- Tag Handler
10- -----------
9+ Response Tagger
10+ ---------------
1111
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 ``.
1515
1616Setup
1717~~~~~
@@ -20,29 +20,28 @@ Setup
2020
2121 Make sure to :doc: `configure your proxy <proxy-configuration >` for tagging first.
2222
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::
2625
27- use FOS\HttpCache\Handler\TagHandler ;
26+ use FOS\HttpCache\ResponseTagger ;
2827
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 );
3130
3231Usage
3332~~~~~
3433
3534With tags you can group related representations so it becomes easier to
3635invalidate 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::
3837
39- $tagHandler ->addTags(['tag-two', 'group-a']);
38+ $responseTagger ->addTags(['tag-two', 'group-a']);
4039
4140Before any content is sent out, you need to send the tag header _::
4241
4342 header(sprintf('%s: %s'),
44- $tagHandler ->getTagsHeaderName(),
45- $tagHandler ->getTagsHeaderValue()
43+ $responseTagger ->getTagsHeaderName(),
44+ $responseTagger ->getTagsHeaderValue()
4645 );
4746
4847.. tip ::
@@ -75,21 +74,21 @@ Only ``/one`` will stay in the cache.
7574
7675.. note ::
7776
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 >`
8279
8380Custom Tags Header
8481~~~~~~~~~~~~~~~~~~
8582
83+ // TOOO: Move or change to reflect that this depends on Proxy Client.
84+
8685Tagging uses a custom HTTP header to identify tags. You can change the default
8786header ``X-Cache-Tags `` in the constructor::
8887
89- use FOS\HttpCache\Handler\TagHandler ;
88+ use FOS\HttpCache\ResponseTagger ;
9089
9190 // $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');
9392
9493Make sure to reflect this change in your
9594:doc: `caching proxy configuration <proxy-configuration >`.
0 commit comments