-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Improve robustness of page cache test for Site Health #10855
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
base: trunk
Are you sure you want to change the base?
Conversation
This commit updates the page cache detection in Site Health by: - Using a stricter regex (\bhit\b) for detecting cache hits in response headers, preventing false positives (e.g., 'shit'). - Adding support for the X-Varnish header, identifying a cache hit when it contains two request IDs. - Adding documentation and source links for the supported headers. - Adding PHPUnit test cases to verify the new detection logic. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
The x-srcache-store-status header uses 'STORE' or 'BYPASS', not 'HIT' or 'MISS'. This update ensures that 'STORE' is correctly identified as a positive page cache indicator. Also includes: - Documentation for srcache headers. - Explicit list of generic caching proxies (Squid, Go, Fastly, LiteSpeed) in comments. - Test cases for x-srcache-store-status and x-srcache-fetch-status. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Gemini review: I have completed the review of the changes committed to the Commit ContextThe changes aim to improve the robustness of page cache detection in WordPress Site Health. Key improvements include:
Code Review
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| 'x-cache-disabled' => static function ( $header_value ) { | ||
| return ( 'on' !== strtolower( $header_value ) ); | ||
| }, | ||
| 'x-srcache-store-status' => $cache_hit_callback, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was incorrect. Now fixed.
This improves the robustness of page cache detection in Site Health by refining the response header validation and expanding support for common caching layers.
Logic & Header Improvements
$cache_hit_callbacknow uses a word-boundary regular expression (/\bhit\b/i) instead of a simple substring check. This prevents false positives from header values likeshit.X-SRCache-Store-StatusCorrection: Fixed the validation for this header to check for the correct valueSTORE(the module's indicator for a successful cache storage) instead ofHIT.X-Varnishheader, specifically identifying a hit when the header contains two request IDs (e.g.,123 456), as documented in the Varnish FAQ.Last-Modified,ETag, andViaas valid indicators of a caching layer, while ensuring they are handled as existence-based detections or validated where appropriate.srcache,Varnish) and explicitly listed supported generic proxies (Squid, Go, Fastly, LiteSpeed) in comments.PHPUnit Test Enhancements
Tests_Admin_wpSiteHealthto verify:X-Varnishhits vs. misses.X-SRCache-Store-Status(STORE) andX-SRCache-Fetch-Status(HIT).x-cache: shit).ETag,Last-Modified, andVia.Code Quality
class-wp-site-health.phpand the test suite usingcomposer formatto ensure adherence to WordPress Coding Standards.Trac ticket: https://core.trac.wordpress.org/ticket/64370
Use of AI Tooling
The above PR description was drafted by Gemini, and Gemini CLI was involved in authoring some commits (as attributed via
co-authored-by).This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.