This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/HttpKernel/HttpCache
Fabien Potencier d17d38d291 bug #26643 Fix that ESI/SSI processing can turn a "private" response "public" (mpdude)
This PR was squashed before being merged into the 2.7 branch (closes #26643).

Discussion
----------

Fix that ESI/SSI processing can turn a "private" response "public"

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Under the condition that
* we are merging in at least one *embedded* response,
* all *embedded* responses are `public`,
* the *main* response is `private` and
* all responses use expiration-based caching (note: no `s-maxage` on the *main* response)

... the resulting response will turn to `Cache-Control: public`.

The real issue is that when all responses use expiration-based caching, a combined max age is computed. This is set on the *main* response using `Response::setSharedMaxAge()`, which implicitly sets `Cache-Control: public`.

The fix provided in this PR solves the problem by applying the same logic to the *main* response that is applied for *embedded* responses, namely that responses with `!Response::isCacheable()` will make the resulting response have `Cache-Control: private, no-cache, must-revalidate` and have `(s)max-age` removed.

This makes the change easy to understand, but makes responses uncacheable too often. This is because the `Response::isCacheable()` method was written to determine whether it is safe for a shared cache to keep the response, which is not the case as soon as a `private` response is involved. This might be improved upon in another PR.

Commits
-------

3d27b5946d Fix that ESI/SSI processing can turn a \"private\" response \"public\"
2018-04-16 19:47:59 +02:00
..
Esi.php [2.7][DX] Use constant message contextualisation for deprecations 2017-12-20 15:36:51 +01:00
EsiResponseCacheStrategy.php fixed some deprecation messages 2017-12-31 05:55:05 +01:00
EsiResponseCacheStrategyInterface.php Don't trigger deprecation on interfaces 2015-08-30 13:26:29 +02:00
HttpCache.php PHP CS Fixer: clean up repo and adjust config 2018-01-03 18:10:15 +01:00
ResponseCacheStrategy.php Fix that ESI/SSI processing can turn a \"private\" response \"public\" 2018-04-16 19:47:52 +02:00
ResponseCacheStrategyInterface.php [DI] minor docblock fixes 2017-10-24 13:40:19 +02:00
Ssi.php removed useless PHPDoc 2017-09-30 07:00:23 -07:00
Store.php [HttpCache] Unlink tmp file on error 2018-03-31 09:59:49 +02:00
StoreInterface.php [DI] minor docblock fixes 2017-10-24 13:40:19 +02:00
SurrogateInterface.php [DI] minor docblock fixes 2017-10-24 13:40:19 +02:00