7
7
Working with Server Side Includes
8
8
=================================
9
9
10
- In a similar way as :doc: `ESI (Edge Side Includes) <esi >`, SSI can be used to
11
- control HTTP caching on fragments of a response. The most important
12
- difference that is SSI is known directly by most web servers like
13
- `Apache <https://httpd.apache.org/docs/current/en/howto/ssi.html >`_,
14
- `Nginx <https://nginx.org/en/docs/http/ngx_http_ssi_module.html >`_ etc.
10
+ In a similar way as :doc: `ESI (Edge Side Includes) </http_cache/esi >`,
11
+ SSI can be used to control HTTP caching on fragments of a response.
12
+ The most important difference that is SSI is known directly by most
13
+ web servers like `Apache `_, `Nginx `_ etc.
15
14
16
- The SSI instructions are done in HTML comments:
15
+ The SSI instructions are done via HTML comments:
17
16
18
17
.. code-block :: html
19
18
@@ -29,15 +28,13 @@ The SSI instructions are done in HTML comments:
29
28
</body >
30
29
</html >
31
30
32
- There is some other `available directives
33
- <https://en.wikipedia.org/wiki/Server_Side_Includes#Directives> `_ but
31
+ There are some other `available directives `_ but
34
32
Symfony manages only the ``#include virtual `` one.
35
33
36
34
.. caution ::
37
35
38
36
Be careful with SSI, your website may be victim of injections.
39
- Please read this OWASP article first:
40
- https://www.owasp.org/index.php/Server-Side_Includes_(SSI)_Injection.
37
+ Please read this `OWASP article `_ first!
41
38
42
39
When the web server reads an SSI directive, it requests the given URI or gives
43
40
directly from its cache. It repeats this process until there is no more
@@ -57,7 +54,6 @@ First, to use SSI, be sure to enable it in your application configuration:
57
54
58
55
# config/packages/framework.yaml
59
56
framework :
60
- # ...
61
57
ssi : { enabled: true }
62
58
63
59
.. code-block :: xml
@@ -73,18 +69,16 @@ First, to use SSI, be sure to enable it in your application configuration:
73
69
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
74
70
75
71
<framework : config >
76
- <!-- ... -->
77
- <framework : ssi enabled =" true" />
72
+ <framework : ssi enabled =" true" />
78
73
</framework : config >
79
74
</container >
80
75
81
76
.. code-block :: php
82
77
83
78
// config/packages/framework.php
84
- $container->loadFromExtension('framework', array(
85
- // ...
86
- 'ssi' => array('enabled' => true),
87
- ));
79
+ $container->loadFromExtension('framework', [
80
+ 'ssi' => ['enabled' => true],
81
+ ]);
88
82
89
83
Suppose you have a page with private content like a Profile page and you want
90
84
to cache a static GDPR content block. With SSI, you can add some expiration
@@ -131,7 +125,7 @@ The ``render_ssi`` twig helper will generate something like:
131
125
132
126
<!-- #include virtual="/_fragment?_hash=abcdef1234&_path=_controller=App\Controller\ProfileController::gdpr" -->
133
127
134
- ``render_esi `` ensures that SSI directive are generated only if the request
128
+ ``render_ssi `` ensures that SSI directive are generated only if the request
135
129
has the header requirement like ``Surrogate-Capability: device="SSI/1.0" ``
136
130
(normally given by the web server).
137
131
Otherwise it will embed directly the sub-response.
@@ -140,3 +134,8 @@ Otherwise it will embed directly the sub-response.
140
134
141
135
For more information about Symfony cache fragments, take a tour on
142
136
the :ref: `ESI documentation <http_cache-fragments >`.
137
+
138
+ .. _`Apache` : https://httpd.apache.org/docs/current/en/howto/ssi.html
139
+ .. _`Nginx` : https://nginx.org/en/docs/http/ngx_http_ssi_module.html
140
+ .. _`available directives` : https://en.wikipedia.org/wiki/Server_Side_Includes#Directives
141
+ .. _`OWASP article` : https://www.owasp.org/index.php/Server-Side_Includes_(SSI)_Injection
0 commit comments