You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug symfony#58015 [HttpKernel] ESI fragment content may be missing in conditional requests (mpdude)
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[HttpKernel] ESI fragment content may be missing in conditional requests
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues |
| License | MIT
The content for ESI-embedded fragments may be missing from the combined (main) response generated by the `HttpCache` under certain conditions:
1. The main request sent to the cache must be a conditional request with either `If-Modified-Since` or `If-None-Match`
2. The embedded response processed by the cache matches the validator (last-modified or etag)
3. The resulting (combined) response generated by the `HttpCache` does not match the validator
Condition 3 is necessary since otherwise the cache returns an empty 304 response. In that case, the issue still exists, but we don't see or care about it and the wrong body is not sent at all.
Regarding condition 2, it does not matter where this embedded response comes from. It may be a fresh (cached) response taken from the cache, it may be a stale cache entry that has been revalidated; probably it can even be a non-cacheable response.
In practice, the conditional request will always use `If-Modified-Since`: We're dealing with ESI subrequests, and the combined response created by the `HttpCache` does not provide `ETag`s, so a client has nothing to validate against.
Only since symfony#42355 (merged in to 6.2) the main response will include a `Last-Modified` header, given that all of the included responses provided one. Probably that is the reason why this bug was not spotted earlier - it required that change and all of the responses processed by the cache must provide `Last-Modified` data.
Conditions 2 + 3 together seem unlikely, but may in fact happen easily when you have an application that generates different chunks of cacheable content for the main and embedded requests and adds last-modified information to them. For example:
* First request: Main response modified at time 1, embedded fragment modified at time 2 -> last-modified at 2
* Data for main response changes at time 3
* Second request with "If-Modified-Since" time 2
* Embedded fragment still modified at time 2, main response at time 3 -> last-modified at 3
* the embedded fragment is considered as not modified, content is stripped
* main response is generated, fragment content is missing
Commits
-------
9fed8dc [HttpKernel] ESI fragment content may be missing in conditional requests
0 commit comments