Skip to content

Commit af081b7

Browse files
committed
Re-organise configuration chapters
Match is now linked to instead of included, and included in the TOC too.
1 parent 0f0cfa6 commit af081b7

File tree

13 files changed

+136
-203
lines changed

13 files changed

+136
-203
lines changed

Resources/doc/features/tagging.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ If your application has many intricate relationships between cached items,
55
which makes it complex to invalidate them by route, cache tagging will be
66
useful.
77

8-
Cache tagging, or more precisely `Tagged Cache Invalidation`_, is a simpler
9-
version of `Linked Cache Invalidation`_ (LCI).
10-
11-
Tagged Cache Invalidation allows you to:
8+
Cache tagging, or more precisely `Tagged Cache Invalidation`_, a simpler
9+
version of `Linked Cache Invalidation`_ (LCI), allows you to:
1210

1311
* assign tags to your applications’s responses (e.g., ``articles``, ``article-42``)
1412
* :ref:`invalidate the responses by tag <foshttpcache:tags>` (e.g., invalidate
@@ -74,7 +72,8 @@ See the :ref:`Cache Manager reference <cache_manager_tags>` for full details.
7472
Configuration
7573
~~~~~~~~~~~~~
7674

77-
Alternatively, you can configure rules for setting and invalidating tags:
75+
Alternatively, you can :doc:`configure rules </reference/configuration/tags>`
76+
for setting and invalidating tags:
7877

7978
.. code-block:: yaml
8079
@@ -91,8 +90,6 @@ Now if a :term:`safe` request matches the criteria under ``match``, the response
9190
will be tagged with ``news``. When an unsafe request matches, the tag ``news``
9291
will be invalidated.
9392

94-
See the :doc:`tags configuration reference </reference/configuration/tags>` for full details.
95-
9693
Annotations
9794
~~~~~~~~~~~
9895

Resources/doc/includes/enabled.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enabled
2+
-------
3+
4+
**type**: ``enum`` **default**: ``auto`` **options**: ``true``, ``false``, ``auto``
5+
6+
Enabled by default if :ref:`ExpressionLanguage is installed <expression language requirement>`
7+
and you have :doc:`configured a proxy client </reference/configuration/proxy-client>`.

Resources/doc/includes/match.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
match
2+
^^^^^
3+
4+
**type**: ``array``
5+
6+
A match definition that when met, will execute the rule effect.
7+
See :doc:`/reference/configuration/match`.

Resources/doc/includes/safe.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. the HTTP request matches *all* criteria defined under ``match``
2+
2. the HTTP request is :term:`safe` (GET or HEAD)
3+
3. the HTTP response is considered :term:`cacheable` (override with
4+
:ref:`additional_cacheable_status` and :ref:`match_response`).

Resources/doc/overview.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ And include it in your project::
5959
// ...
6060
);
6161

62+
.. _expression language requirement:
63+
6264
ExpressionLanguage
6365
~~~~~~~~~~~~~~~~~~
6466

Resources/doc/reference/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ for the bundle.
1414
configuration/user-context
1515
configuration/flash-message
1616
configuration/debug
17+
configuration/match

Resources/doc/reference/configuration/debug.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Debug Header
2-
============
1+
debug
2+
=====
33

44
Enable the ``debug`` parameter to set a custom header (``X-Cache-Debug``)
55
header on each response. You can then
@@ -26,7 +26,7 @@ dev mode but not in prod mode.
2626
header
2727
------
2828

29-
**type**: ``string`` **default**: ``X-Cache-Debug**
29+
**type**: ``string`` **default**: ``X-Cache-Debug``
3030

3131
Custom HTTP header that triggers the caching proxy to set debugging information
3232
on the response.

Resources/doc/reference/configuration/headers.rst

Lines changed: 29 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
Caching Headers
2-
===============
1+
cache_control
2+
=============
33

44
The configuration contains a number of *rules*. When a request matches the
55
parameters described in the ``match`` section, the headers as defined under
6-
``headers`` will be set on its response.
7-
8-
The match patterns are applied in the order specified, where the first match
9-
wins:
6+
``headers`` will be set on the response, if they are not already set.
107

118
.. code-block:: yaml
129
@@ -40,13 +37,19 @@ wins:
4037
# match everything to set defaults
4138
-
4239
match:
43-
path: ^/
40+
path: ^/
4441
headers:
4542
cache_control: { public: true, max_age: 15, s_maxage: 30, last_modified: "-1 hour" }
4643
4744
rules
4845
-----
4946

47+
**type**: ``array``
48+
49+
A set of cache control rules.
50+
51+
.. include:: /includes/match.rst
52+
5053
.. sidebar:: Merging headers
5154

5255
If the response already has certain cache directives set, they are not
@@ -68,113 +71,10 @@ rules
6871
service ``fos_http_cache.event_listener.cache_control`` and calling
6972
``setSkip()`` on it. If this method is called, no cache rules are applied.
7073

71-
The configuration contains a number of *rules*. When a request matches the
72-
parameters described in the ``match`` section, the headers as defined under
73-
``headers`` will be set on the response, if they are not already set.
74-
75-
The match patterns are applied in the order specified, where the first match
76-
wins.
77-
78-
.. _match:
79-
80-
match
81-
-----
82-
83-
The headers are only set if all of these are true:
84-
85-
* the request matches *all* criteria defined under ``match``
86-
* the request is :term:`safe` (GET or HEAD)
87-
* the response is considered :term:`cacheable` (override with
88-
:ref:`additional_cacheable_status` and :ref:`match_response`).
89-
90-
All matching criteria are regular expressions.
91-
92-
path
93-
~~~~
94-
95-
For example, ``path: ^/`` will match every request. To only match the home
96-
page, use ``path: ^/$``.
97-
98-
host
99-
~~~~
100-
101-
A regular expression to limit the caching rules to specific hosts, when you
102-
serve more than one host from your Symfony application.
103-
104-
.. tip::
105-
106-
To simplify caching of a site that at the same time has frontend
107-
editing, put the editing on a separate (sub-)domain. Then define a first
108-
rule matching that domain with ``host`` and set ``max-age: 0`` to make sure
109-
your caching proxy never caches the editing domain.
110-
111-
methods
112-
~~~~~~~
113-
114-
Can be used to limit caching rules to specific HTTP methods like GET requests.
115-
116-
Note that cache headers are not applied to methods not considered *safe*, not
117-
even when the methods are listed in this configuration.
118-
119-
ips
120-
~~~
121-
122-
An array that can be used to limit the rules to a specified set of request
123-
client IP addresses.
124-
125-
.. note::
126-
127-
If you use a caching proxy and want specific IPs to see different headers,
128-
you need to forward the client IP to the backend. Otherwise, the backend
129-
only sees the caching proxy IP. See `Trusting Proxies`_ in the Symfony
130-
documentation.
131-
132-
attributes
133-
~~~~~~~~~~
134-
135-
An array to filter on route attributes. the most common use case would be
136-
``_controller`` when you need caching rules applied to a controller. Note that
137-
this is the controller name used in the route, so it depends on your route
138-
configuration whether you need ``Bundle:Name:action`` or
139-
``service.id:methodName`` (if you defined your `controllers as services`_).
140-
141-
Note that even for the request attributes, your criteria are interpreted as
142-
regular expressions.
143-
144-
.. _additional_cacheable_status:
145-
146-
additional_cacheable_status
147-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
148-
149-
A list of additional HTTP status codes of the response for which to also apply
150-
the rule.
151-
152-
.. _match_response:
153-
154-
match_response
155-
~~~~~~~~~~~~~~
156-
157-
.. note::
158-
159-
``match_response`` :ref:`requires the ExpressionLanguage component <requirements>`.
160-
161-
An ExpressionLanguage expression to decide whether the response should have
162-
the headers applied. If not set, headers are applied if the request is
163-
:term:`safe`. The expression can access the ``Response`` object with the
164-
``response`` variable. For example, to handle all failed requests, you can do:
165-
166-
.. code-block:: yaml
167-
168-
-
169-
match:
170-
match_response: response.getStatusCode() >= 400
171-
# ...
172-
173-
You can not set both ``match_response`` and ``additional_cacheable_status``
174-
inside the same rule.
175-
17674
headers
177-
-------
75+
^^^^^^^
76+
77+
**type**: ``array``
17878

17979
.. sidebar:: YAML alias for same headers for different matches
18080

@@ -208,7 +108,9 @@ In the ``headers`` section, you define what headers to set on the response if
208108
the request was matched.
209109

210110
cache_control
211-
~~~~~~~~~~~~~
111+
"""""""""""""
112+
113+
**type**: ``array``
212114

213115
The map under ``cache_control`` is set in a call to ``Response::setCache()``.
214116
The names are specified with underscores in yml, but translated to ``-`` for
@@ -245,7 +147,7 @@ default. If you want it respected, add your own logic to ``vcl_fetch``.
245147

246148
The cache-control headers are described in detail in :rfc:`2616#section-14.9`.
247149

248-
Extra cache control directives
150+
Extra Cache Control Directives
249151
""""""""""""""""""""""""""""""
250152

251153
You can also set headers that Symfony considers non-standard, some coming from
@@ -278,7 +180,9 @@ directives are flags that are included when set to true.
278180
no_transform: true
279181
280182
last_modified
281-
~~~~~~~~~~~~~
183+
"""""""""""""
184+
185+
**type**: ``string``
282186

283187
The input to the ``last_modified`` is used for the ``Last-Modified`` header.
284188
This value must be a valid input to ``DateTime``.
@@ -300,7 +204,9 @@ This value must be a valid input to ``DateTime``.
300204
from the cache if it was not invalidated since the client requested it.
301205

302206
vary
303-
~~~~
207+
""""
208+
209+
**type**: ``string``
304210

305211
You can set the `vary` option to an array that defines the contents of the
306212
`Vary` header when matching the request. This adds to existing Vary headers,
@@ -316,8 +222,12 @@ keeping previously set Vary options.
316222
headers:
317223
vary: My-Custom-Header
318224
319-
reverse_proxy_ttl for X-Reverse-Proxy-TTL for Custom Reverse Proxy Time-Outs
320-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225+
reverse_proxy_ttl
226+
"""""""""""""""""
227+
228+
**type**: ``integer``
229+
230+
For X-Reverse-Proxy-TTL for Custom Reverse Proxy Time-Outs
321231

322232
By default, reverse proxies use the ``s-maxage`` of your ``Cache-Control`` header
323233
to know how long it should cache a page. But by default, the s-maxage is also
@@ -367,6 +277,3 @@ you need to extend your varnish ``vcl_fetch`` configuration:
367277
Note that there is a ``beresp.ttl`` field in VCL but unfortunately it can only
368278
be set to absolute values and not dynamically. Thus we have to revert to a C
369279
code fragment.
370-
371-
.. _Trusting Proxies: http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html
372-
.. _controllers as services: http://symfony.com/doc/current/cookbook/controller/service.html

Resources/doc/reference/configuration/invalidation.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
Invalidation Configuration
2-
==========================
1+
invalidation
2+
============
3+
4+
Configure :ref:`invalidation<invalidation configuration>` to invalidate
5+
routes when some other routes are requested.
36

47
.. code-block:: yaml
58
69
# app/config/config.yml
710
fos_http_cache:
811
invalidation:
9-
enabled: true # Defaults to 'auto'
12+
enabled: true # Defaults to 'auto'
1013
rules:
1114
-
1215
match:
@@ -17,26 +20,23 @@ Invalidation Configuration
1720
villain_details: # e.g., /villain/{id}
1821
ignore_extra_params: false # Defaults to true
1922
20-
enabled
21-
-------
22-
23-
**type**: ``enum`` **default**: ``auto`` **options**: ``true``, ``false``, ``auto``
24-
25-
Enabled by default if ExpressionLanguage is installed and you have configured
26-
the Cache Manager.
23+
.. include:: /includes/enabled.rst
2724

2825
rules
2926
-----
3027

3128
**type**: ``array``
3229

33-
A set of invalidation rules. Each rule consists of a matcher and one or more
34-
routes that will be invalidated. The routes are only invalidated when:
30+
A set of invalidation rules. Each rule consists of a match definition and
31+
one or more routes that will be invalidated. The routes are invalidated when:
32+
33+
1. the HTTP request matches *all* criteria defined under ``match``
34+
2. the HTTP response is successful.
3535

36-
.. include:: match.rst
36+
.. include:: /includes/match.rst
3737

3838
routes
39-
~~~~~~
39+
^^^^^^
4040

4141
**type**: ``array``
4242

0 commit comments

Comments
 (0)