-
Notifications
You must be signed in to change notification settings - Fork 384
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
Improve page cache detection test #6849
Conversation
Plugin builds for 1d25cc4 are ready 🛎️!
|
Codecov Report
@@ Coverage Diff @@
## develop #6849 +/- ##
=============================================
+ Coverage 78.46% 78.52% +0.06%
- Complexity 6735 6764 +29
=============================================
Files 202 202
Lines 20321 20395 +74
=============================================
+ Hits 15944 16015 +71
- Misses 4377 4380 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
E2E tests seem to be stalling. I don't think they're related to this PR. cc @delawski |
Here are the scenarios I'm testing: Failure to Do Loopback RequestWith this plugin active: add_action('template_redirect', function () {
status_header( 500 );
exit;
}); No Page Caching with Slow Response TimeWith this plugin active: add_action( 'wp_footer', function () {
sleep(1);
} ); No Page Caching with Good Response TimeNo special plugins active. Page Caching Header(s) with Bad Response TimeTest plugin: add_filter(
'wp_headers',
function ( $headers ) {
$headers['etag'] = '"foo"';
$headers['last-modified'] = gmdate('r');
return $headers;
}
);
add_action( 'wp_footer', function () {
sleep(1);
} ); Note that since page caching response headers are present, the lack of a page caching plugin is not mentioned (since it's likely an external page cache is being used): Page Caching Header with Good Response TimePlugin: add_filter(
'wp_headers',
function ( $headers ) {
$headers['etag'] = '"foo"';
$headers['last-modified'] = gmdate('r');
return $headers;
}
); Note that since page caching response headers are present, the lack of a page caching plugin is not mentioned (since it's likely an external page cache is being used): Page Caching Plugin with Good Response TimeWith WP Super Cache active and with the following plugin active: add_action( 'wp_footer', function () {
sleep(1);
} ); Note that since the median time is used, the 1-second response time is disregarded: |
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 is a huge improvement. Way more robust.
The only thing outstanding are the failing E2E tests.
src/Admin/SiteHealth.php
Outdated
if ( empty( $page_cache_detail['response_time'] ) ) { | ||
$page_cache_test_summary[] = '<span class="dashicons dashicons-dismiss text-error"></span> ' . __( 'Server response time could not be determined. Verify that loopback requests are working.', 'amp' ); |
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.
Note: I don't believe this scenario is ever possibly reached.
8ff39b5
to
c7dd6ab
Compare
…h::get_page_cache_status()
686de21
to
4a4c490
Compare
I've looked into the E2E tests issue and wasn't able to find the reason for it. Since I wasn't able to reproduce the issue locally, I had to play a guessing game on this. First, I tried changing the selector that fails in multiple unit tests (90d9a16). It didn't help. Then, I thought that maybe AMP plugin is not activated on the test environment for whatever reason (maybe new WordPress 5.9 or the recent update of Gutenberg npm packages?). I've added a rule to try activating the plugin from within E2E tests (4a4c490). It didn't help as well. Lastly, I've rebased the branch onto One more thing I did was to issue a new PR for another feature I just completed working on #6859. I branched off of I don't have more time to investigate the issue further today. |
I'm gonna push up some commits to debug this. I'll be doing some force-pushes to beware. |
d323217
to
188e0cd
Compare
It turns out the E2E tests were working perfectly! They were catching an actual problem which I've fixed in 188e0cd. The issue is it wasn't accounting for @delawski Thank you for wrestling with this in any case! |
Summary
Fixes #6830
This PR improves the mechanism to detect page caching availability on websites.
Checklist