From 52f171fb7919ee9560961d88c870c61beaa92cd5 Mon Sep 17 00:00:00 2001
From: Philipp Rieber
Date: Mon, 16 Dec 2013 08:35:27 +0100
Subject: [PATCH 1/2] [HTTP Cache] Fix typo, improve code samples
---
book/http_cache.rst | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/book/http_cache.rst b/book/http_cache.rst
index b84b6a534db..28dd2e99b38 100644
--- a/book/http_cache.rst
+++ b/book/http_cache.rst
@@ -301,9 +301,9 @@ The ``Cache-Control`` header is unique in that it contains not one, but various
pieces of information about the cacheability of a response. Each piece of
information is separated by a comma:
- Cache-Control: private, max-age=0, must-revalidate
+ Cache-Control: private, max-age=0, must-revalidate
- Cache-Control: max-age=3600, must-revalidate
+ Cache-Control: max-age=3600, must-revalidate
Symfony provides an abstraction around the ``Cache-Control`` header to make
its creation more manageable::
@@ -662,7 +662,7 @@ exposing a simple and efficient pattern::
// a database or a key-value store for instance)
$article = ...;
- // create a Response with a ETag and/or a Last-Modified header
+ // create a Response with an ETag and/or a Last-Modified header
$response = new Response();
$response->setETag($article->computeETag());
$response->setLastModified($article->getPublishedAt());
@@ -674,17 +674,17 @@ exposing a simple and efficient pattern::
if ($response->isNotModified($this->getRequest())) {
// return the 304 Response immediately
return $response;
- } else {
- // do more work here - like retrieving more data
- $comments = ...;
-
- // or render a template with the $response you've already started
- return $this->render(
- 'MyBundle:MyController:article.html.twig',
- array('article' => $article, 'comments' => $comments),
- $response
- );
}
+
+ // do more work here - like retrieving more data
+ $comments = ...;
+
+ // or render a template with the $response you've already started
+ return $this->render(
+ 'MyBundle:MyController:article.html.twig',
+ array('article' => $article, 'comments' => $comments),
+ $response
+ );
}
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
header, which is a comma-separated list of different headers whose values
trigger a different representation of the requested resource:
-.. code-block:: text
-
Vary: Accept-Encoding, User-Agent
.. tip::
@@ -951,8 +949,9 @@ component cache will only last for 60 seconds.
When using a controller reference, the ESI tag should reference the embedded
action as an accessible URL so the gateway cache can fetch it independently of
the rest of the page. Symfony2 takes care of generating a unique URL for any
-controller reference and it is able to route them properly thanks to a
-listener that must be enabled in your configuration:
+controller reference and it is able to route them properly thanks to the
+:class:`Symfony\\Component\\HttpKernel\\EventListener\\FragmentListener`
+that must be enabled in your configuration:
.. configuration-block::
@@ -1058,10 +1057,10 @@ Here is how you can configure the Symfony2 reverse proxy to support the
}
$response = new Response();
- if (!$this->getStore()->purge($request->getUri())) {
- $response->setStatusCode(404, 'Not purged');
- } else {
+ if ($this->getStore()->purge($request->getUri())) {
$response->setStatusCode(200, 'Purged');
+ } else {
+ $response->setStatusCode(404, 'Not purged');
}
return $response;
From fe925bcae6bcbb79dc722b0649164f5c1d22e0e9 Mon Sep 17 00:00:00 2001
From: Philipp Rieber
Date: Mon, 16 Dec 2013 12:24:15 +0100
Subject: [PATCH 2/2] Fix text block inconsistency
---
book/http_cache.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/book/http_cache.rst b/book/http_cache.rst
index 28dd2e99b38..bdedb5b3135 100644
--- a/book/http_cache.rst
+++ b/book/http_cache.rst
@@ -301,6 +301,8 @@ The ``Cache-Control`` header is unique in that it contains not one, but various
pieces of information about the cacheability of a response. Each piece of
information is separated by a comma:
+.. code-block:: text
+
Cache-Control: private, max-age=0, must-revalidate
Cache-Control: max-age=3600, must-revalidate
@@ -716,6 +718,8 @@ request's ``Accept-Encoding`` value. This is done by using the ``Vary`` response
header, which is a comma-separated list of different headers whose values
trigger a different representation of the requested resource:
+.. code-block:: text
+
Vary: Accept-Encoding, User-Agent
.. tip::