[6.x] Fix stale static cache status on responses in long-lived processes - #15455
Merged
jasonvarga merged 1 commit intoSep 14, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static caching keeps a small lookup table that remembers, for each response, whether it was served from the static cache. That table is keyed by the response's PHP object id, and entries are never removed.
In a normal PHP-FPM request that's harmless: the whole process ends with the request, and the table dies with it. In a long-lived process (e.g. Octane, queue workers) the same PHP process handles many requests, so two things go wrong:
wasStaticallyCached()can say "yes" for a response that was never cached.The fix
Key the table by the response object itself using PHP's
WeakMap(added in PHP 8.0), which is a map whose entries are dropped automatically as soon as the object they belong to is gone. No stale ids, no cleanup to remember, and the map never grows past the responses that are still alive. No public API changes: thesetStaticCacheResponseStatus,staticCacheResponseStatus, andwasStaticallyCachedmacros behave exactly as before.