Skip to content

Commit 52f171f

Browse files
committed
[HTTP Cache] Fix typo, improve code samples
1 parent 7c038bf commit 52f171f

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

book/http_cache.rst

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ The ``Cache-Control`` header is unique in that it contains not one, but various
301301
pieces of information about the cacheability of a response. Each piece of
302302
information is separated by a comma:
303303

304-
Cache-Control: private, max-age=0, must-revalidate
304+
Cache-Control: private, max-age=0, must-revalidate
305305

306-
Cache-Control: max-age=3600, must-revalidate
306+
Cache-Control: max-age=3600, must-revalidate
307307

308308
Symfony provides an abstraction around the ``Cache-Control`` header to make
309309
its creation more manageable::
@@ -662,7 +662,7 @@ exposing a simple and efficient pattern::
662662
// a database or a key-value store for instance)
663663
$article = ...;
664664

665-
// create a Response with a ETag and/or a Last-Modified header
665+
// create a Response with an ETag and/or a Last-Modified header
666666
$response = new Response();
667667
$response->setETag($article->computeETag());
668668
$response->setLastModified($article->getPublishedAt());
@@ -674,17 +674,17 @@ exposing a simple and efficient pattern::
674674
if ($response->isNotModified($this->getRequest())) {
675675
// return the 304 Response immediately
676676
return $response;
677-
} else {
678-
// do more work here - like retrieving more data
679-
$comments = ...;
680-
681-
// or render a template with the $response you've already started
682-
return $this->render(
683-
'MyBundle:MyController:article.html.twig',
684-
array('article' => $article, 'comments' => $comments),
685-
$response
686-
);
687677
}
678+
679+
// do more work here - like retrieving more data
680+
$comments = ...;
681+
682+
// or render a template with the $response you've already started
683+
return $this->render(
684+
'MyBundle:MyController:article.html.twig',
685+
array('article' => $article, 'comments' => $comments),
686+
$response
687+
);
688688
}
689689

690690
When the ``Response`` is not modified, the ``isNotModified()`` automatically sets
@@ -716,8 +716,6 @@ request's ``Accept-Encoding`` value. This is done by using the ``Vary`` response
716716
header, which is a comma-separated list of different headers whose values
717717
trigger a different representation of the requested resource:
718718

719-
.. code-block:: text
720-
721719
Vary: Accept-Encoding, User-Agent
722720

723721
.. tip::
@@ -951,8 +949,9 @@ component cache will only last for 60 seconds.
951949
When using a controller reference, the ESI tag should reference the embedded
952950
action as an accessible URL so the gateway cache can fetch it independently of
953951
the rest of the page. Symfony2 takes care of generating a unique URL for any
954-
controller reference and it is able to route them properly thanks to a
955-
listener that must be enabled in your configuration:
952+
controller reference and it is able to route them properly thanks to the
953+
:class:`Symfony\\Component\\HttpKernel\\EventListener\\FragmentListener`
954+
that must be enabled in your configuration:
956955

957956
.. configuration-block::
958957

@@ -1058,10 +1057,10 @@ Here is how you can configure the Symfony2 reverse proxy to support the
10581057
}
10591058

10601059
$response = new Response();
1061-
if (!$this->getStore()->purge($request->getUri())) {
1062-
$response->setStatusCode(404, 'Not purged');
1063-
} else {
1060+
if ($this->getStore()->purge($request->getUri())) {
10641061
$response->setStatusCode(200, 'Purged');
1062+
} else {
1063+
$response->setStatusCode(404, 'Not purged');
10651064
}
10661065

10671066
return $response;

0 commit comments

Comments
 (0)