Gets page cache details.
Source
private function get_page_cache_detail() {
$page_cache_detail = $this->check_for_page_caching();
if ( is_wp_error( $page_cache_detail ) ) {
return $page_cache_detail;
}
// Use the median server response time.
$response_timings = $page_cache_detail['response_timing'];
rsort( $response_timings );
$page_speed = $response_timings[ floor( count( $response_timings ) / 2 ) ];
// Obtain unique set of all client caching response headers.
$headers = array();
foreach ( $page_cache_detail['page_caching_response_headers'] as $page_caching_response_headers ) {
$headers = array_merge( $headers, array_keys( $page_caching_response_headers ) );
}
$headers = array_unique( $headers );
// Page cache is detected if there are response headers or a page cache plugin is present.
$has_page_caching = ( count( $headers ) > 0 || $page_cache_detail['advanced_cache_present'] );
if ( $page_speed && $page_speed < $this->get_good_response_time_threshold() ) {
$result = $has_page_caching ? 'good' : 'recommended';
} else {
$result = 'critical';
}
return array(
'status' => $result,
'advanced_cache_present' => $page_cache_detail['advanced_cache_present'],
'headers' => $headers,
'response_time' => $page_speed,
);
}
Changelog
Version | Description |
---|---|
6.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.