@@ -105,14 +105,15 @@ independently of the rest of the page::
105105 public function about()
106106 {
107107 $response = $this->render('static/about.html.twig');
108- // sets the shared max age - which also marks the response as public
109- $response->setSharedMaxAge (600);
108+ $ response->setPublic();
109+ $response->setMaxAge (600);
110110
111111 return $response;
112112 }
113113 }
114114
115- In this example, the full-page cache has a lifetime of ten minutes.
115+ In this example, the response is marked as public to make the full page
116+ cacheable for all requests with a lifetime of ten minutes.
116117Next, include the news ticker in the template by embedding an action.
117118This is done via the ``render() `` helper (for more details, see how to
118119:ref: `embed controllers in templates <templates-embed-controllers >`).
@@ -170,14 +171,19 @@ of the master page::
170171 public function latest($maxPerPage)
171172 {
172173 // ...
173- $response->setSharedMaxAge(60);
174+ $response->setPublic();
175+ $response->setMaxAge(60);
174176
175177 return $response;
176178 }
177179 }
178180
179- With ESI, the full page cache will be valid for 600 seconds, but the news
180- component cache will only last for 60 seconds.
181+ In this example, the embedded action is cached publicly too because the contents
182+ are the same for all requests. However, in other cases you may need to make this
183+ response non-public and even non-cacheable, depending on your needs.
184+
185+ Putting all the above code together, with ESI the full page cache will be valid
186+ for 600 seconds, but the news component cache will only last for 60 seconds.
181187
182188.. _http_cache-fragments :
183189
@@ -233,14 +239,6 @@ possible.
233239 signed when using the fragment renderer and the ``render_esi `` Twig
234240 function.
235241
236- .. note ::
237-
238- Once you start using ESI, remember to always use the ``s-maxage ``
239- directive instead of ``max-age ``. As the browser only ever receives the
240- aggregated resource, it is not aware of the sub-components, and so it will
241- obey the ``max-age `` directive and cache the entire page. And you don't
242- want that.
243-
244242The ``render_esi `` helper supports two other useful options:
245243
246244``alt ``
0 commit comments