Skip to content

[HTTP Cache] typo; improve/simplify code samples; formatting #3350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 26, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down Expand Up @@ -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());
Expand All @@ -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
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the beginning of the chapter there is an example for the Cache-Control header, it it using a simple box. But the Vary header example here is using a different format - a text block. So either the Cache-Control example should become a text block or the Vary example should become a normal box. What do you think?

See also my comment in the Conversation tab.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simple box actually is a rendered as a blockquote. Thus, I'd change the Cache-Control example since a code block better fits the meaning.


.. tip::
Expand Down Expand Up @@ -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::

Expand Down Expand Up @@ -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;
Expand Down