Permalink
Browse files

minor #3596 [HTTP Cache] Validation model: Fix header name (bicpi)

This PR was merged into the 2.3 branch.

Discussion
----------

[HTTP Cache] Validation model: Fix header name

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | -

In the cache validation model, the response sends an `ETag` header, but the following requests send an `If-None-Match` header. So the `If-None-Match` header from the request is compared to the `ETag` from the previous response. See `Symfony\Component\HttpFoundation\Request::getETags()` which is used by `Symfony\Component\HttpFoundation\Response::isNotModified()`.

Commits
-------

f7ef7c0 [HTTP Cache] Validation model: Fix header name
  • Loading branch information...
weaverryan committed Mar 8, 2014
2 parents 0ab1f24 + f7ef7c0 commit 58b7f96781f3696fbfaa8adc2f4504b986405161
Showing with 10 additions and 3 deletions.
  1. +10 −3 book/http_cache.rst
View
@@ -572,9 +572,16 @@ To see a simple implementation, generate the ETag as the md5 of the content::
}
The :method:`Symfony\\Component\\HttpFoundation\\Response::isNotModified`
method compares the ``ETag`` sent with the ``Request`` with the one set
on the ``Response``. If the two match, the method automatically sets the
``Response`` status code to 304.
method compares the ``If-None-Match`` sent with the ``Request`` with the
``ETag`` header set on the ``Response``. If the two match, the method
automatically sets the ``Response`` status code to 304.
.. note::
The ``If-None-Match`` request header equals the ``ETag`` header of the
last response sent to the client for the particular resource. This is
how the client and server communicate with each other and decide whether
or not the resource has been updated since it was cached.
This algorithm is simple enough and very generic, but you need to create the
whole ``Response`` before being able to compute the ETag, which is sub-optimal.

0 comments on commit 58b7f96

Please sign in to comment.