Skip to content
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

Add Site Health test to verify that static assets are served with far-future expires #1727

Open
wants to merge 27 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dc9e364
Add site health checks for far-future expiration headers
b1ink0 Dec 9, 2024
4cb07aa
Add filter for customizing far-future headers threshold
b1ink0 Dec 9, 2024
ec9a552
Refactor far-future headers checks and improve asset validation logic
b1ink0 Dec 9, 2024
dd8e70d
Merge branch 'trunk' into add/far-future-expiration-test
b1ink0 Dec 9, 2024
0078cfc
Use assets from wp-includes for far-future headers site health check
b1ink0 Dec 10, 2024
3e5d958
Add filter to customize assets checked for far-future headers
b1ink0 Dec 10, 2024
35e7977
Enhance far-future headers check to return detailed results and gener…
b1ink0 Dec 10, 2024
3db5886
Improve far-future headers checks by adding detailed failure reasons …
b1ink0 Dec 10, 2024
655d4e5
Add test to ensure status is 'good' when all headers are valid
b1ink0 Dec 11, 2024
20099bf
Add test for assets with conditional caching
b1ink0 Dec 12, 2024
54f3621
Add test for status messages based on far-future headers results
b1ink0 Dec 12, 2024
0a776c5
Add tests for filters affecting far-future headers asset checks
b1ink0 Dec 12, 2024
3c98337
Refactor to use filenames instead of extenstions in failure details
b1ink0 Dec 12, 2024
7afd746
Filter assets to ensure only string URLs are checked
b1ink0 Jan 8, 2025
3fcd641
Update parameter type hints for far-future headers functions
b1ink0 Jan 8, 2025
54c73ec
Merge branch 'trunk' into add/far-future-expiration-test
b1ink0 Jan 8, 2025
6a2da47
Include max-age, expires actual value and threshold value in error me…
b1ink0 Jan 9, 2025
48166ac
Simplify filename extraction and conditional logic
b1ink0 Jan 9, 2025
17d380e
Refactor header checks to use null coalescing and improve conditionals
b1ink0 Jan 9, 2025
200b518
Fix far future headers tests failing due to updated error messages
b1ink0 Jan 9, 2025
1b4cef4
Improve error messages for far future headers check
b1ink0 Jan 10, 2025
ed28196
Merge branch 'trunk' into add/far-future-expiration-test
b1ink0 Jan 10, 2025
ee3a57d
Update labels to make them less technical
b1ink0 Jan 15, 2025
f6ba392
Add cover annotations for tests and test for when no assets are passed
b1ink0 Jan 15, 2025
0620840
Mark functions as private
b1ink0 Jan 15, 2025
7ebdc87
Merge branch 'trunk' into add/far-future-expiration-test
b1ink0 Jan 16, 2025
49ca83f
Add covers tags
westonruter Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
<?php
/**
* Helper function to detect if static assets have far-future expiration headers.
*
* @package performance-lab
* @since n.e.x.t
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.

Check warning on line 10 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L9-L10

Added lines #L9 - L10 were not covered by tests
}

/**
* Callback for the far-future caching test.
*
* @since n.e.x.t
* @access private
*
* @return array{label: string, status: string, badge: array{label: string, color: string}, description: string, actions: string, test: string} Result.
*/
function perflab_ffh_assets_test(): array {
$result = array(
'label' => __( 'Your site serves static assets with an effective caching strategy', 'performance-lab' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance', 'performance-lab' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
esc_html__(
'Serving static assets with far-future expiration headers improves performance by allowing browsers to cache files for a long time, reducing repeated requests.',
'performance-lab'
)
),
'actions' => '',
'test' => 'is_far_future_headers_enabled',
);

// List of assets to check.
$assets = array(
includes_url( 'js/wp-embed.min.js' ),
includes_url( 'css/buttons.min.css' ),
includes_url( 'fonts/dashicons.woff2' ),
includes_url( 'images/media/video.png' ),
);
westonruter marked this conversation as resolved.
Show resolved Hide resolved

/**
* Filters the list of assets to check for far-future headers.
*
* @since n.e.x.t
*
* @param string[] $assets List of asset URLs to check.
*/
$assets = apply_filters( 'perflab_ffh_assets_to_check', $assets );
westonruter marked this conversation as resolved.
Show resolved Hide resolved
$assets = array_filter( (array) $assets, 'is_string' );

// Check if far-future headers are enabled for all assets.
$results = perflab_ffh_check_assets( $assets );

if ( 'good' !== $results['final_status'] ) {
$result['status'] = $results['final_status'];
$result['label'] = __( 'Your site does not serve static assets with an effective caching strategy', 'performance-lab' );

if ( count( $results['details'] ) > 0 ) {
$result['actions'] = sprintf(
'<p>%s</p>%s<p>%s</p>',
esc_html__( 'The following file types do not have the recommended far-future headers. Consider adding or adjusting Cache-Control or Expires headers for these asset types.', 'performance-lab' ),
perflab_ffh_get_extensions_table( $results['details'] ),
esc_html__( 'Note: "Conditionally cached" means that the browser can re-validate the resource using ETag or Last-Modified headers. This results in fewer full downloads but still requires the browser to make requests, unlike far-future expiration headers that allow the browser to fully rely on its local cache for a longer duration.', 'performance-lab' )
);
}
$result['actions'] .= sprintf(
'<p>%s</p>',
esc_html__( 'Far-future Cache-Control or Expires headers can be added or adjusted with a small configuration change by your hosting provider.', 'performance-lab' )
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two different checks which are getting performed one with Cache-Control, Expires and other with Etag, Last-Modified should there be different messages shown based on the checks?

Copy link
Contributor Author

@b1ink0 b1ink0 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the new 3db5886 commit a table is used to display reason for different failure cases.


return $result;
}

/**
* Checks if far-future expiration headers are enabled for a list of assets.
*
* @since n.e.x.t
* @access private
*
* @param string[] $assets List of asset URLs to check.
* @return array{final_status: string, details: array{filename: string, reason: string}[]} Final status and details.
*/
function perflab_ffh_check_assets( array $assets ): array {
$final_status = 'good';
$fail_details = array(); // Array of arrays with 'filename' and 'reason'.

foreach ( $assets as $asset ) {
$response = wp_remote_get( $asset, array( 'sslverify' => false ) );

// Extract filename from the URL.
$path_info = pathinfo( (string) wp_parse_url( $asset, PHP_URL_PATH ) );
$filename = $path_info['basename'] ?? basename( $asset );

if ( is_wp_error( $response ) ) {
// Can't determine headers if request failed, consider it a fail.
$final_status = 'recommended';
$fail_details[] = array(
'filename' => $filename,
'reason' => __( 'Could not retrieve headers', 'performance-lab' ),
);
continue;

Check warning on line 109 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L104-L109

Added lines #L104 - L109 were not covered by tests
}

$headers = wp_remote_retrieve_headers( $response );
if ( ! is_object( $headers ) && 0 === count( $headers ) ) {
// No valid headers retrieved.
$final_status = 'recommended';
$fail_details[] = array(
'filename' => $filename,
'reason' => __( 'No valid headers retrieved', 'performance-lab' ),
);
continue;

Check warning on line 120 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L115-L120

Added lines #L115 - L120 were not covered by tests
}
Comment on lines +102 to +121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two if statements lack tests, but I don't think they are critical.


$check = perflab_ffh_check_headers( $headers );
if ( isset( $check['passed'] ) && $check['passed'] ) {
// This asset passed far-future headers test, no action needed.
continue;
}

// If not passed, decide whether to try conditional request.
if ( false === $check ) {
Comment on lines +123 to +130
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditions here seem a bit confusing to me, related to how perflab_ffh_check_headers() returns either an array or false. I think it would be preferable if perflab_ffh_check_headers always returned an array. Maybe it could always return an array key for missing_max_age which is a boolean. And then this could be changed to:

Suggested change
$check = perflab_ffh_check_headers( $headers );
if ( isset( $check['passed'] ) && $check['passed'] ) {
// This asset passed far-future headers test, no action needed.
continue;
}
// If not passed, decide whether to try conditional request.
if ( false === $check ) {
$check = perflab_ffh_check_headers( $headers );
if ( $check['passed'] ) {
// This asset passed far-future headers test, no action needed.
continue;
}
// If not passed, decide whether to try conditional request.
if ( $check['missing_max_age'] ) {

// Only if no far-future headers at all, we try conditional request.
$conditional_pass = perflab_ffh_try_conditional_request( $asset, $headers );
$final_status = 'recommended';
if ( ! $conditional_pass ) {
$fail_details[] = array(
'filename' => $filename,
'reason' => __( 'No far-future headers and no conditional caching', 'performance-lab' ),
);
} else {
$fail_details[] = array(
'filename' => $filename,
'reason' => __( 'No far-future headers but conditionally cached', 'performance-lab' ),
);
}
} else {
// If there's a max-age or expires but below threshold, we skip conditional.
$final_status = 'recommended';
$fail_details[] = array(
'filename' => $filename,
'reason' => $check['reason'],
);
}
}

return array(
'final_status' => $final_status,
'details' => $fail_details,
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently even if one asset fails the header check then this test will be show in the site health. Would it be better to show a table with mime type which will specifically tell for which mime type needs to add the Cache-Control headers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A table makes sense to me.


/**
* Checks if far-future expiration headers are enabled.
*
* @since n.e.x.t
* @access private
*
* @param WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string|array<string>> $headers Response headers.
* @return array{passed: bool, reason: string}|false Detailed result. If passed=false, reason explains why it failed and false if no headers found.
*/
function perflab_ffh_check_headers( $headers ) {
/**
* Filters the threshold for far-future headers.
*
* @since n.e.x.t
*
* @param int $threshold Threshold in seconds.
*/
$threshold = apply_filters( 'perflab_far_future_headers_threshold', YEAR_IN_SECONDS );

Check warning on line 178 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L178

Added line #L178 was not covered by tests

$cache_control = $headers['cache-control'] ?? '';
$expires = $headers['expires'] ?? '';

Check warning on line 181 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L180-L181

Added lines #L180 - L181 were not covered by tests

// Check Cache-Control header for max-age.
$max_age = 0;
if ( '' !== $cache_control ) {

Check warning on line 185 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L184-L185

Added lines #L184 - L185 were not covered by tests
// There can be multiple cache-control headers, we only care about max-age.
foreach ( (array) $cache_control as $control ) {
if ( 1 === preg_match( '/max-age\s*=\s*(\d+)/', $control, $matches ) ) {
$max_age = (int) $matches[1];
break;

Check warning on line 190 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L187-L190

Added lines #L187 - L190 were not covered by tests
}
}
}

// If max-age meets or exceeds the threshold, we consider it good.
if ( $max_age >= $threshold ) {
return array(
'passed' => true,
'reason' => '',
);

Check warning on line 200 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L196-L200

Added lines #L196 - L200 were not covered by tests
}

// If max-age is too low or not present, check Expires.
if ( is_string( $expires ) && '' !== $expires ) {
$expires_time = strtotime( $expires );
$remaining_time = is_int( $expires_time ) ? $expires_time - time() : 0;
if ( $remaining_time >= $threshold ) {

Check warning on line 207 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L204-L207

Added lines #L204 - L207 were not covered by tests
// Good - Expires far in the future.
return array(
'passed' => true,
'reason' => '',
);

Check warning on line 212 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L209-L212

Added lines #L209 - L212 were not covered by tests
}

// Expires header exists but not far enough in the future.
if ( $max_age > 0 ) {
return array(
'passed' => false,
'reason' => sprintf(

Check warning on line 219 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L216-L219

Added lines #L216 - L219 were not covered by tests
/* translators: 1: actual max-age value in seconds, 2: threshold in seconds */
__( 'max-age below threshold (actual: %1$s seconds, threshold: %2$s seconds)', 'performance-lab' ),
number_format_i18n( $max_age ),
number_format_i18n( $threshold )
),
);

Check warning on line 225 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L221-L225

Added lines #L221 - L225 were not covered by tests
Comment on lines +217 to +225
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a test is missing for the max-age being present but it not being high enough.

}
return array(
'passed' => false,
'reason' => sprintf(

Check warning on line 229 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L227-L229

Added lines #L227 - L229 were not covered by tests
/* translators: 1: actual Expires header value in seconds, 2: threshold in seconds */
__( 'expires below threshold (actual: %1$s seconds, threshold: %2$s seconds)', 'performance-lab' ),
number_format_i18n( $remaining_time ),
number_format_i18n( $threshold )
),
);

Check warning on line 235 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L231-L235

Added lines #L231 - L235 were not covered by tests
}

// No max-age or expires found at all or max-age < threshold and no expires.
if ( 0 === $max_age ) {
return false;

Check warning on line 240 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L239-L240

Added lines #L239 - L240 were not covered by tests
} else {
// max-age was present but below threshold and no expires.
return array(
'passed' => false,
'reason' => sprintf(

Check warning on line 245 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L243-L245

Added lines #L243 - L245 were not covered by tests
/* translators: 1: actual max-age value in seconds, 2: threshold in seconds */
__( 'max-age below threshold (actual: %1$s seconds, threshold: %2$s seconds)', 'performance-lab' ),
number_format_i18n( $max_age ),
number_format_i18n( $threshold )
),
);

Check warning on line 251 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L247-L251

Added lines #L247 - L251 were not covered by tests
}
}

/**
* Attempt a conditional request with ETag/Last-Modified.
*
* @since n.e.x.t
* @access private
*
* @param string $url The asset URL.
* @param WpOrg\Requests\Utility\CaseInsensitiveDictionary|array<string, string|array<string>> $headers The initial response headers.
* @return bool True if a 304 response was received.
*/
function perflab_ffh_try_conditional_request( string $url, $headers ): bool {
$etag = isset( $headers['etag'] ) ? $headers['etag'] : '';
$last_modified = isset( $headers['last-modified'] ) ? $headers['last-modified'] : '';

Check warning on line 267 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L266-L267

Added lines #L266 - L267 were not covered by tests
Comment on lines +266 to +267
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor improvement.

Suggested change
$etag = isset( $headers['etag'] ) ? $headers['etag'] : '';
$last_modified = isset( $headers['last-modified'] ) ? $headers['last-modified'] : '';
$etag = $headers['etag'] ?? '';
$last_modified = $headers['last-modified'] ?? '';


$conditional_headers = array();
if ( '' !== $etag ) {
$conditional_headers['If-None-Match'] = $etag;

Check warning on line 271 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L269-L271

Added lines #L269 - L271 were not covered by tests
}
if ( '' !== $last_modified ) {
$conditional_headers['If-Modified-Since'] = $last_modified;

Check warning on line 274 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L273-L274

Added lines #L273 - L274 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like test coverage for this line is warranted.

}

$response = wp_remote_get(
$url,
array(
'sslverify' => false,
'headers' => $conditional_headers,
)
);

Check warning on line 283 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L277-L283

Added lines #L277 - L283 were not covered by tests

if ( is_wp_error( $response ) ) {
return false;

Check warning on line 286 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L285-L286

Added lines #L285 - L286 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a test for this case, although not critical.

}

$status_code = wp_remote_retrieve_response_code( $response );
return ( 304 === $status_code );

Check warning on line 290 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L289-L290

Added lines #L289 - L290 were not covered by tests
}

/**
* Generate a table listing files that need far-future headers, including reasons.
*
* @since n.e.x.t
* @access private
*
* @param array<array{filename: string, reason: string}> $fail_details Array of arrays with 'filename' and 'reason'.
* @return string HTML formatted table.
*/
function perflab_ffh_get_extensions_table( array $fail_details ): string {
$html_table = sprintf(
'<table class="widefat striped"><thead><tr><th scope="col">%s</th><th scope="col">%s</th></tr></thead><tbody>',
esc_html__( 'File', 'performance-lab' ),
esc_html__( 'Status', 'performance-lab' )
);

Check warning on line 307 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L303-L307

Added lines #L303 - L307 were not covered by tests

foreach ( $fail_details as $detail ) {
$html_table .= sprintf(
'<tr><td>%s</td><td>%s</td></tr>',
esc_html( $detail['filename'] ),
esc_html( $detail['reason'] )
);

Check warning on line 314 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L309-L314

Added lines #L309 - L314 were not covered by tests
}

$html_table .= '</tbody></table>';

Check warning on line 317 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L317

Added line #L317 was not covered by tests

return $html_table;

Check warning on line 319 in plugins/performance-lab/includes/site-health/far-future-headers/helper.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/helper.php#L319

Added line #L319 was not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Hook callbacks used for far-future headers.
*
* @package performance-lab
* @since n.e.x.t
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.

Check warning on line 10 in plugins/performance-lab/includes/site-health/far-future-headers/hooks.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/hooks.php#L9-L10

Added lines #L9 - L10 were not covered by tests
}

/**
* Adds tests to site health.
*
* @since n.e.x.t
* @access private
*
* @param array{direct: array<string, array{label: string, test: string}>} $tests Site Health Tests.
* @return array{direct: array<string, array{label: string, test: string}>} Amended tests.
*/
function perflab_ffh_add_test( array $tests ): array {
$tests['direct']['far_future_headers'] = array(
'label' => __( 'Effective Caching Headers', 'performance-lab' ),
'test' => 'perflab_ffh_assets_test',
);
return $tests;

Check warning on line 27 in plugins/performance-lab/includes/site-health/far-future-headers/hooks.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/hooks.php#L23-L27

Added lines #L23 - L27 were not covered by tests
}
add_filter( 'site_status_tests', 'perflab_ffh_add_test' );

Check warning on line 29 in plugins/performance-lab/includes/site-health/far-future-headers/hooks.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/far-future-headers/hooks.php#L29

Added line #L29 was not covered by tests
Comment on lines +22 to +29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A trivial function to add a test for, but it would ensure test coverage.

4 changes: 4 additions & 0 deletions plugins/performance-lab/includes/site-health/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@
// AVIF headers site health check.
require_once __DIR__ . '/avif-headers/helper.php';
require_once __DIR__ . '/avif-headers/hooks.php';

// Far-Future Headers site health check.
require_once __DIR__ . '/far-future-headers/helper.php';
require_once __DIR__ . '/far-future-headers/hooks.php';

Check warning on line 35 in plugins/performance-lab/includes/site-health/load.php

View check run for this annotation

Codecov / codecov/patch

plugins/performance-lab/includes/site-health/load.php#L34-L35

Added lines #L34 - L35 were not covered by tests
Loading
Loading