diff --git a/plugins/performance-lab/includes/site-health/bfcache-compatibility-headers/helper.php b/plugins/performance-lab/includes/site-health/bfcache-compatibility-headers/helper.php index 2a5077337..4a58c5997 100644 --- a/plugins/performance-lab/includes/site-health/bfcache-compatibility-headers/helper.php +++ b/plugins/performance-lab/includes/site-health/bfcache-compatibility-headers/helper.php @@ -22,13 +22,16 @@ */ function perflab_bfcache_compatibility_headers_check(): array { $result = array( - 'label' => __( 'The Cache-Control response header for pages ensures fast back/forward navigation.', 'performance-lab' ), + 'label' => __( 'The Cache-Control page header is compatible with fast back/forward navigations', 'performance-lab' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Performance', 'performance-lab' ), 'color' => 'blue', ), - 'description' => '
' . esc_html__( 'If the Cache-Control response header includes directives like no-store, no-cache, or max-age=0 then it can prevent instant back/forward navigations (using the browser bfcache). Your site is configured properly.', 'performance-lab' ) . '
', + 'description' => '' . wp_kses(
+ __( 'If the Cache-Control
page response header includes directives like no-store
, no-cache
, or max-age=0
then it can prevent instant back/forward navigations (using the browser bfcache). Your site is configured properly.', 'performance-lab' ),
+ array( 'code' => array() )
+ ) . '
' . wp_kses(
sprintf(
/* translators: 1: the error code, 2: the error message */
- __( 'The request to check the Cache-Control response header responded with error code %1$s
and the following error message: %2$s.', 'performance-lab' ),
+ __( 'The request to check the Cache-Control
response header for the home page resulted in an error with code %1$s
and the following message: %2$s.', 'performance-lab' ),
esc_html( (string) $response->get_error_code() ),
esc_html( rtrim( $response->get_error_message(), '.' ) )
),
array( 'code' => array() )
) . '
%s
', - sprintf( - /* translators: %s: Cache-Control header value */ - esc_html__( 'Cache-Control headers are set to %s. This can affect the performance of your site by preventing fast back/forward navigations (via browser bfcache).', 'performance-lab' ), - $flagged_headers_string - ) + '%s %s
', + wp_kses( + sprintf( + /* translators: %s: problematic directive(s) */ + _n( + 'TheCache-Control
response header for the home page includes the following directive: %s.',
+ 'The Cache-Control
response header for the home page includes the following directives: %s.',
+ count( $flagged_headers ),
+ 'performance-lab'
+ ),
+ implode(
+ ', ',
+ array_map(
+ static function ( $header ) {
+ return "$header
";
+ },
+ $flagged_headers
+ )
+ )
+ ),
+ array( 'code' => array() )
+ ),
+ esc_html__( 'This can affect the performance of your site by preventing fast back/forward navigations (via browser bfcache).', 'performance-lab' )
);
break;
}
diff --git a/plugins/performance-lab/tests/includes/site-health/bfcache-compatibility-headers/test-bfcache-compatibility-headers.php b/plugins/performance-lab/tests/includes/site-health/bfcache-compatibility-headers/test-bfcache-compatibility-headers.php
index 30945ed13..52fbbbffb 100644
--- a/plugins/performance-lab/tests/includes/site-health/bfcache-compatibility-headers/test-bfcache-compatibility-headers.php
+++ b/plugins/performance-lab/tests/includes/site-health/bfcache-compatibility-headers/test-bfcache-compatibility-headers.php
@@ -82,32 +82,32 @@ public function data_test_bfcache_compatibility(): array {
'headers_not_set' => array(
$this->build_response( 200, array( 'cache-control' => '' ) ),
'good',
- 'If the Cache-Control response header includes directives like no-store, no-cache, or max-age=0 then it can prevent instant back/forward navigations (using the browser bfcache). Your site is configured properly.',
+ 'If the Cache-Control
page response header includes directives like',
),
'no_store' => array(
$this->build_response( 200, array( 'cache-control' => 'no-store' ) ),
'recommended',
- 'Cache-Control headers are set to no-store',
+ 'The Cache-Control
response header for the home page includes the following directive: no-store
',
),
'no_cache' => array(
$this->build_response( 200, array( 'cache-control' => 'no-cache' ) ),
'recommended',
- 'Cache-Control headers are set to no-cache',
+ 'The Cache-Control
response header for the home page includes the following directive: no-cache
',
),
'max_age_0' => array(
$this->build_response( 200, array( 'cache-control' => 'max-age=0' ) ),
'recommended',
- 'Cache-Control headers are set to max-age=0',
+ 'The Cache-Control
response header for the home page includes the following directive: max-age=0
',
),
'max_age_0_no_store' => array(
$this->build_response( 200, array( 'cache-control' => 'max-age=0, no-store' ) ),
'recommended',
- 'Cache-Control headers are set to no-store, max-age=0',
+ 'The Cache-Control
response header for the home page includes the following directives: no-store
, max-age=0
',
),
'error' => array(
new WP_Error( 'http_request_failed', 'HTTP request failed' ),
'recommended',
- 'The request to check the Cache-Control response header responded with error code',
+ 'The request to check the Cache-Control
response header for the home page resulted in an error with code',
),
);
}