@@ -301,9 +301,11 @@ The ``Cache-Control`` header is unique in that it contains not one, but various
301
301
pieces of information about the cacheability of a response. Each piece of
302
302
information is separated by a comma:
303
303
304
- Cache-Control: private, max-age=0, must-revalidate
304
+ .. code-block :: text
305
+
306
+ Cache-Control: private, max-age=0, must-revalidate
305
307
306
- Cache-Control: max-age=3600, must-revalidate
308
+ Cache-Control: max-age=3600, must-revalidate
307
309
308
310
Symfony provides an abstraction around the ``Cache-Control `` header to make
309
311
its creation more manageable::
@@ -385,7 +387,7 @@ header when none is set by the developer by following these rules:
385
387
* If ``Cache-Control `` is empty (but one of the other cache headers is present),
386
388
its value is set to ``private, must-revalidate ``;
387
389
388
- * But if at least one ``Cache-Control `` directive is set, and no ' public' or
390
+ * But if at least one ``Cache-Control `` directive is set, and no `` public `` or
389
391
``private `` directives have been explicitly added, Symfony2 adds the
390
392
``private `` directive automatically (except when ``s-maxage `` is set).
391
393
@@ -667,7 +669,7 @@ exposing a simple and efficient pattern::
667
669
// a database or a key-value store for instance)
668
670
$article = ...;
669
671
670
- // create a Response with a ETag and/or a Last-Modified header
672
+ // create a Response with an ETag and/or a Last-Modified header
671
673
$response = new Response();
672
674
$response->setETag($article->computeETag());
673
675
$response->setLastModified($article->getPublishedAt());
@@ -679,17 +681,17 @@ exposing a simple and efficient pattern::
679
681
if ($response->isNotModified($request)) {
680
682
// return the 304 Response immediately
681
683
return $response;
682
- } else {
683
- // do more work here - like retrieving more data
684
- $comments = ...;
685
-
686
- // or render a template with the $response you've already started
687
- return $this->render(
688
- 'MyBundle:MyController:article.html.twig',
689
- array('article' => $article, 'comments' => $comments),
690
- $response
691
- );
692
684
}
685
+
686
+ // do more work here - like retrieving more data
687
+ $comments = ...;
688
+
689
+ // or render a template with the $response you've already started
690
+ return $this->render(
691
+ 'MyBundle:MyController:article.html.twig',
692
+ array('article' => $article, 'comments' => $comments),
693
+ $response
694
+ );
693
695
}
694
696
695
697
When the ``Response `` is not modified, the ``isNotModified() `` automatically sets
@@ -956,8 +958,9 @@ component cache will only last for 60 seconds.
956
958
When using a controller reference, the ESI tag should reference the embedded
957
959
action as an accessible URL so the gateway cache can fetch it independently of
958
960
the rest of the page. Symfony2 takes care of generating a unique URL for any
959
- controller reference and it is able to route them properly thanks to a
960
- listener that must be enabled in your configuration:
961
+ controller reference and it is able to route them properly thanks to the
962
+ :class: `Symfony\\ Component\\ HttpKernel\\ EventListener\\ FragmentListener `
963
+ that must be enabled in your configuration:
961
964
962
965
.. configuration-block ::
963
966
@@ -1063,10 +1066,10 @@ Here is how you can configure the Symfony2 reverse proxy to support the
1063
1066
}
1064
1067
1065
1068
$response = new Response();
1066
- if (!$this->getStore()->purge($request->getUri())) {
1067
- $response->setStatusCode(Response::HTTP_NOT_FOUND, 'Not purged');
1068
- } else {
1069
+ if ($this->getStore()->purge($request->getUri())) {
1069
1070
$response->setStatusCode(Response::HTTP_OK, 'Purged');
1071
+ } else {
1072
+ $response->setStatusCode(Response::HTTP_NOT_FOUND, 'Not purged');
1070
1073
}
1071
1074
1072
1075
return $response;
@@ -1104,6 +1107,6 @@ Learn more from the Cookbook
1104
1107
.. _`validation model` : http://tools.ietf.org/html/rfc2616#section-13.3
1105
1108
.. _`RFC 2616` : http://tools.ietf.org/html/rfc2616
1106
1109
.. _`HTTP Bis` : http://tools.ietf.org/wg/httpbis/
1107
- .. _`P4 - Conditional Requests` : http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-12
1108
- .. _`P6 - Caching: Browser and intermediary caches` : http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-12
1110
+ .. _`P4 - Conditional Requests` : http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional
1111
+ .. _`P6 - Caching: Browser and intermediary caches` : http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache
1109
1112
.. _`ESI` : http://www.w3.org/TR/esi-lang
0 commit comments